Here you can find the source of newDocument()
public static Document newDocument()
//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; public class Main { private static DocumentBuilderFactory mFactory = null; /**//from w w w. j a v a2s.co m * @return A new document to populate */ public static Document newDocument() { ensureFactory(); try { DocumentBuilder builder = mFactory.newDocumentBuilder(); return builder.newDocument(); } catch (ParserConfigurationException e) { return null; } } private static synchronized void ensureFactory() { if (mFactory == null) { mFactory = DocumentBuilderFactory.newInstance(); //mFactory.setIgnoringComments(true); mFactory.setValidating(false); mFactory.setCoalescing(true); mFactory.setExpandEntityReferences(false); } } }