Guest googenfrog Posted September 8, 2008 Share Posted September 8, 2008 Hello all...How do i merge two xml files into one using javascript? Is this the same as appending. Thanks Link to comment Share on other sites More sharing options...
boen_robot Posted September 8, 2008 Share Posted September 8, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.