[
Lists Home 
Date Index 
Thread Index
]
This result doesn't sound correct. What does your code look like?
 Ron
Sean Zhang wrote:
>
> I'm having problem assigning attribute values to child nodes of the newly
> cloned node. I'm using Xerces J v1.4.1
>
> Following is what I did
>
> 1. I'm using cloneNode(true) to deep copy a node. This is successful.
>
> For example, below is the original node
> <level1 attr1="1">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
>
> below is the newly cloned node
> <level1 attr1="1">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
>
> Then I start to assign values to the attributes of the newly cloned node. I
> plan to assign value for the new node as below
> <level1 attr1="3">
> <level2 attr2="4.1"/>
> <level2 attr2="4.2"/>
> </level1>
>
> finally, I will append the newly cloned node to the parent of the original
> node
>
> below is what I should have after appending the newly cloned node
> <level1 attr1="1">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
> <level1 attr1="3">
> <level2 attr2="4.1"/>
> <level2 attr2="4.2"/>
> </level1>
>
> But I received follow
> <level1 attr1="1">
> <level2 attr2="4.1"/>
> <level2 attr2="4.2"/>
> </level1>
> <level1 attr1="3">
> <level2 attr2="2.1"/>
> <level2 attr2="2.2"/>
> </level1>
>
> Seems to me that attribute values for level1 node is correctly assigned and
> new values for child nodes for level1 are not assigned to the newly cloned
> node but assigned to the original node.
>
> Is this the correct behavior? How can I assign the values to the newly
> cloned node without affecting the original node?
