[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Problem with cloneNode
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? Thanks, Sean
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|