I am trying to insert a node element (which has some child elements) from one XML to another in java.
What I'm trying (which doesn't work) looks like this:
Node foo = document1.getChildNodes().item(3).cloneNode(true);
document2.getChildNodes().item(2).appendChild(foo);
I get an exception that complains that I'm trying to use the node created by one document in another.
Is there an alternative not recursing through doc1 node and creating all this manually in doc2?
source
share