[xmljs-users] deep copy nodes between xml documents with JS
Brought to you by:
djoham,
witchhunter
From: Barry B. <Ba...@al...> - 2004-12-06 07:58:03
|
hi all I've got a simple xml doc loaded on a page. I then get an additional xml doc using the xmlhttprequest object. what I want to do is get a deep copy of a particular node from the additional doc and append it to the first one. I've tried importNode(), various combinations of cloneNode(), et all, but can't seem to snag it. can anyone see where I'm going wrong? thanx barry.b here's the JS, run after the xmlhttprequest object gets each additional doc function addAddressToMasterDoc(xmlAddress){ var addressNode =3D xmlAddress.firstChild; masterXmlDoc.importNode(addressNode); }=20 masterXmlDoc (before): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= <entity id=3D"12345" type=3D"student"> <fname>Fred</fname> <lname>Flintstone</lname> </entity> xmlAddress: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D <address addrType=3D"residential"> <addr1>12 stone st</addr1> <addr2>Bedrock</addr2> </address> masterXmlDoc (after - what I'm trying to get): =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D <entity id=3D"12345" type=3D"student"> <fname>Fred</fname> <lname>Flintstone</lname> <address addrType=3D"residential"> <addr1>12 stone st</addr1> <addr2>Bedrock</addr2> </address> </entity> |