Java tutorial
//package com.java2s; //License from project: Apache License import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { public static Document newDocument() { try { DocumentBuilderFactory xmlFactory = DocumentBuilderFactory.newInstance(); xmlFactory.setNamespaceAware(true); DocumentBuilder builder = xmlFactory.newDocumentBuilder(); return builder.newDocument(); } catch (Exception e) { e.printStackTrace(); return null; } } }