Copy an XML document
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class Utils {
/**
* Copy an XML document, adding it as a child of the target document root
* @param source Document to copy
* @param target Document to contain copy
*/
public static void copyDocument(Document source, Document target)
{
Node node = target.importNode(source.getDocumentElement(), true);
target.getDocumentElement().appendChild(node);
}
}
Related examples in the same category