You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Chris Haggan <c_...@hotmail.com> on 2001/06/29 14:19:21 UTC
Deep cloning or Node renaming.. help required.
Hi, first message so I'll keep it brief.
If I want to copy a large structure from another XML document will a deep
clone allow this? I was reading the documentation and it seemed slightly
contradictory. Does a deep clone recurse through all sub-nodes or just the
current node and it's direct children?
Essentially what I have is:
<ADD_RFQ>
<CONTROL_AREA>
<CONTACT_INFO>
<ADDRESS></ADDRESS>
</CONTACT_INFO>
</CONTROL_AREA>
</ADD_RFQ>
And I need:
<ADD_QUOTE>
<CONTROL_AREA>
<CONTACT_INFO>
<ADDRESS></ADDRESS>
</CONTACT_INFO>
</CONTROL_AREA>
</ADD_QUOTE>
Is there an easy way of doing this? (There's no rename node or it'd be a
simple job).
Any help greatly appreciated.
Chris H
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: Deep cloning or Node renaming.. help required.
Posted by Paul Brown <pr...@fivesight.com>.
> From: Chris Haggan [mailto:c_haggan@hotmail.com]
> If I want to copy a large structure from another XML document will a
> deep clone allow this?
Yes.
> I was reading the documentation and it seemed slightly
> contradictory. Does a deep clone recurse through all sub-nodes or just
> the current node and it's direct children?
It's recursive.
> Essentially what I have is:
> [rename an element]
> Is there an easy way of doing this? (There's no rename node or it'd be
> a simple job).
To rename an element "old", you'll need to get the owner document, create a
new element "nu", copy over the attributes from "old" to "nu", append the
children of "old" to "nu" (this effects a move, not a copy), and then call
replaceChild to put the new element in place.
Moving nodes moves the whole subtree under the node, as DOM nodes are only
linked by references. (That is, if you move the parent, you automatically
move all children.)
-- Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org