Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; public class Main { /** * Creates a new empty DOM {@link Document}. * * @return the created {@code Document}. */ public static Document createEmptyDomDocument() { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); return documentBuilder.newDocument(); } catch (ParserConfigurationException e) { throw new RuntimeException("Internal error: ParserConfigurationException: " + e.getMessage()); } } }