I\'m developing a website using the Seam framework and the RichFaces AJAX library (these isn\'t really all that important to the problem at hand - just some background).
In IE you can simply use the xml
property of the XML node, provided newnode
really is an XML node rather than an HTML node:
function serializeXmlNode(xmlNode) {
if (typeof window.XMLSerializer != "undefined") {
return (new window.XMLSerializer()).serializeToString(xmlNode);
} else if (typeof xmlNode.xml != "undefined") {
return xmlNode.xml;
}
return "";
}
oldnode.outerHTML = serializeXmlNode(newnode);
I wouldn't use outerHTML
to replace an element. It's not universally supported. Instead, you could use a mix of innerHTML
and standard DOM methods as follows:
var tempEl = document.createElement("div");
tempEl.innerHTML = serializeXmlNode(newnode);
oldnode.parentNode.replaceChild(oldnode, tempEl.firstChild);