Java tutorial
//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() { try { return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { // How can a vanilla instance throw a configuration exception? e.printStackTrace(); assert false : e.getMessage(); throw new RuntimeException(e); } } }