Java tutorial
//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 { /** * Creates an empty JAXP XML document. * * @return An empty JAXP XML document. */ public static Document getNewEmptyJAXPDoc() { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder; try { documentBuilder = documentBuilderFactory.newDocumentBuilder(); return documentBuilder.newDocument(); } catch (ParserConfigurationException e) { e.printStackTrace(); } return null; } }