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 { public static Document newDocument() { try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(true); DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); return builder.newDocument(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } } }