I’m having issues parsing some XML using DefaultHandler2. My XML takes the following form:
<nodeA>
<nodeB></nodeB>
<nodeB></nodeB>
</nodeA>
I’m trying to create DOM Document of the XML, however according to the Javadoc about Node.appendChild:
“Adds the node newChild to the end of the list of children of this
node. If the newChild is already in the tree, it is first removed.”
Thus the 1st nodeB element is removed, I’m wondering how to add sibling nodes of the same name using the Document class. Any info on this would be great, thanks muchly!
Node.appendChild will remove and re-add a node only if it is the same instance, not type. So, you should be adding new instances of the child node types each time rather than changing and reappending the same object.