Here you can find the source of newXMLDocument()
public static Document newXMLDocument()
//package com.java2s; //License from project: Open Source License import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Node; public class Main { public static Document newXMLDocument() { try {/*from www. j av a2s .c o m*/ return newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new RuntimeException(e.getMessage()); } } public static Document newXMLDocument(Node node) { Document doc = newXMLDocument(); doc.appendChild(doc.importNode(node, true)); return doc; } public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { return newDocumentBuilderFactory().newDocumentBuilder(); } public static DocumentBuilderFactory newDocumentBuilderFactory() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); return dbf; } }