Here you can find the source of createDocument()
public static Document createDocument()
//package com.java2s; // Published under GNU General Public License conditions. import javax.xml.parsers.*; import org.w3c.dom.*; public class Main { /**/*www . jav a 2 s . c o m*/ * Creation of a XML DOM document. * * This is a convenience method which returns an XML document * without any danger of throwing an exception. * All exceptions are converted to \b null values. * * @return XML DOM Document object, or \b null in the case of failure */ public static Document createDocument() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { System.out.println("!!! DOM creation exception"); System.out.println(e.toString()); } Document doc = builder.newDocument(); return doc; } }