[thelist] XMLHttpObject, responseXML and MSIE

Kasimir K evolt at kasimir-k.fi
Sat Feb 12 05:59:27 CST 2005


Hello,

I've been playing around with XMLHTTPObject [0]. What I want to do is 
call a document fragment from the server side, and then append it to 
existing document. With Firefox this happens nicely, the XMLHttpObject 
calls back this:

function testCallBack(xho)
{
    var el = document.importNode(xho.responseXML.documentElement, true);
    document.getElementById('stub').appendChild(el);
}

Unfortunately on MSIE this is not so straight forward. To start with, 
MSIE does not implement importNode. I tried overcome this by

function impNode(node)
{
    var importNode = document.createElement("div");
    importNode.innerHTML = node.xml.toString();
    return importNode.firstChild;
}

but MSIE gives me type mismatch errors.

It looks like MSIE does not want to append XML document fragments into a 
HTML document.

I guess I could traverse the XML DOM, and just make a copy with 
document.createElement of its each node, but somehow that doesn't look 
like a streamlined solution.

When I was googling for this, I encountered mostly use of responseText, 
not so of responseXML, and of those few it was with MSIE XML islands.

So is there a nice way to pull a document (fragment) from the server, 
and append it in an existing document (on MSIE too)?

muchas gracias,
.k

[0]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmobjpmexmlhttprequest.asp
http://www.mozilla.org/xmlextras/

http://jibbering.com/2002/4/httprequest.html
http://developer.apple.com/internet/webcontent/xmlhttpreq.html



More information about the thelist mailing list