Jump to content

merging two xml files into an output file using javascript


Guest googenfrog

Recommended Posts

Pretty much... however, there's one method that the browser must support (importNode), and I'm not sure how well it is supported across browsers, so problems are to be expected.Assuming you're using something like W3Schools' loadXMLDoc() function, you can have:

var xml1 = loadXMLDoc('xml1.xml');var xml2 = loadXMLDoc('xml2.xml');//You can use any element here...//the chosen element will be the document element of the new XML documentvar newXML = document.getElementById('combiner');//And actually append the other XML documents to this onenewXML.appendChild(document.importNode(xml1.documentElement));newXML.appendChild(document.importNode(xml2.documentElement));//newXML now contains the whole contents of both XML documents

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...