RE: [xmljs-users] deep copy nodes between xml documents with JS
Brought to you by:
djoham,
witchhunter
|
From: Barry B. <Ba...@al...> - 2004-12-16 04:14:35
|
ach, I've narrowed it down. It's the adding of the other doc's element
to the fragment that it doesn't like
// xmlToAdd and masterXmlDoc are both xml docs
addrToAdd =3D xmlToAdd.documentElement;
doc_frag =3D masterXmlDoc.createDocumentFragment();
doc_frag.appendChild(addrToAdd); ////// here \\\\\
masterAddressRoot =3D
masterXmlDoc.getElementsByTagName("addresses").item(0);
masterAddressRoot.appendChild(doc_frag);
alert(masterXmlDoc);=20
I've seen lots of examples where the "guts" of the fragment is created
(createElement) but no where is it an existing node of another doc.
is this the correct reference to the other xml node?
thanx
barry.b
BTW, this works just fine
addrToAdd =3D xmlToAdd.documentElement;
// get the parent the "address" node
masterAddressRoot =3D
masterXmlDoc.getElementsByTagName("addresses").item(0);
doc_frag =3D masterAddressRoot.importNode(addrToAdd, true);
masterAddressRoot.appendChild(doc_frag);
alert(masterXmlDoc);
-----Original Message-----
From: David Joham [mailto:dj...@ya...]=20
Sent: Wednesday, 15 December 2004 2:13 AM
To: Barry Beattie; xml...@li...
Subject: RE: [xmljs-users] deep copy nodes between xml documents with JS
> all I gotta do is turn "xmlFragment" (not a real DocumentFragment yet)
> into something I can insert into the master=20
>=20
> there isn't really a copyNode(deep) or insertFragment(node) is
there...
Creating a DOMDocumentFragment and inserting it into the document using
the standard
append*/insert* methods should do the trick for you.
http://xmljs.sourceforge.net/website/documentation-w3cdom-DOMDocument.ht
ml#DOMDocumentCreateDocumentFragment
David
|