// Note that this function responds to the
onload
event on the
// tag.
function start() {
// First create a DocumentFragment node.
var myDocFrag = xml.createDocumentFragment();
// Let's also create two elements.
var elem1 = xml.createElement("elem1");
var elem2 = xml.createElement("elem2");
// Now let's insert these two Element nodes into
// the DocumentFragment.
myDocFrag.insertBefore(elem1, null);
myDocFrag.insertBefore(elem2, null);
// Now that we have finished collecting nodes
// let's insert them under the
rootElement
Element.
xml.documentElement.insertBefore(myDocFrag, null);
// Now let's view the resulting XML document.
alert(xml.xml);
}
...
| |