How do I copy DOM nodes from one document to another in Java?
The problem is that Node’s contain a lot of internal state about their context, which includes their parentage and the document by which they are owned. Neither adoptChild() nor importNode() place the new node anywhere in the destination document, which is why your code is failing. Since you want to copy the node and not … Read more