This Java tip illustrates a method of creating an empty DOM document. Java provides a class DocumentBuilder which provides functionality of creating documents. Developer may create various kind of documents using this class.

 public static Document createDomDocument() {
        try {
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document doc = builder.newDocument();
            return doc;
        } catch (ParserConfigurationException e) {
        return null;