I remember well that using the DOM implementation to create new HTML elements on a document was considered to be very much slower than assigning an HTML string to the 'innerHTML' property of the applicable HTML element.
Does the same apply when authoring XML documents using JavaScript? Rather than using the DOM implementation's various create methods, would it be faster to just generate the XML string and parsing it?
Just something I wondered about.... :)
*EDIT - Added an example *
Which is faster? (I'll be using jQuery's parseXML function to do the parsing example):
var myXdoc = $.parseXML("<person><name>Bob</name><relation>Uncle</relation>");
Or
var myXdoc
if (window.ActiveXObject) {
myXdoc = new ActiveXObject("Microsoft.XMLDOM");
myXdoc.async = false;
}
else if (document.implementation && document.implementation.createDocument)
myXdoc = document.implementation.createDocument("", "", null);
var p = myXdoc.documentElement.appendChild(myXdoc.createElement("person"));
var n = p.appendChild(myXdoc.createElement("name"));
n.appendChild(myXdoc.createTextNode("Bob"));
var r = p.appendChild(myXdoc.createElement("relation"));
r.appendChild(myXdoc.createTextNode("Uncle"));
innerHTMLto to parse an xml string? Or is there aninnerXmlimplementation I don't know about?