Here you can find the source of newDocument()
public static Document newDocument() throws ParserConfigurationException
//package com.java2s; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; public class Main { public static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); public static Document newDocument() throws ParserConfigurationException { factory.setNamespaceAware(true); factory.setExpandEntityReferences(true); return factory.newDocumentBuilder().newDocument(); }//from www .j a v a 2s .c o m }