Here you can find the source of createDocument()
public static Document createDocument()
//package com.java2s; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; public class Main { public static Document createDocument() { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true);//from www .j a va 2 s . co m try { return dbf.newDocumentBuilder().newDocument(); } catch (final ParserConfigurationException e) { throw new RuntimeException(); } } }