Here you can find the source of newDocument()
public static Document newDocument()
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; public class Main { /** Construct a new empty document. */ public static Document newDocument() { try {/*ww w .j a v a2 s . c o m*/ return newBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new RuntimeException("Cannot create new document", e); } } private static DocumentBuilder newBuilder() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setExpandEntityReferences(false); factory.setIgnoringComments(true); factory.setCoalescing(true); return factory.newDocumentBuilder(); } }