In java xml file I am trying to add a element to connection node using appendchild. I wanted the existing server node to get replaced with the new value but it is not happening .
I see in the documentation for this function that the existing node will be removed.
win2k8
The javadoc says:
That does not mean, that the tag with the same name will be replaced. It means, the
Nodeobject will be first removed if it already is inside the parent, and it’s about passing a reference to aNodethat is already added to the parent, not about XML tags.If you want to replace the existing XML element with your own, I suggest first finding (by iterating over the
NodeListreturned formgetChildNodes()) and removing unwanted elements withremoveChild(node).