Java tutorial
import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Utils { /** * Copy a Node from one source document, adding it to the document * root of a different, target Document * @param source Document to copy * @param target Document to contain copy */ public static void copyDocumentNode(Node source, Document target) { Node node = target.importNode(source, true); target.getDocumentElement().appendChild(node); } }