Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.*; public class Main { static DocumentBuilderFactory dbFactory = null; static DocumentBuilderFactory dbFactoryForNameSpaceBuilders; public static Document newDocumentNS() throws Exception { DocumentBuilder parser = dbFactoryForNameSpaceBuilders.newDocumentBuilder(); return parser.newDocument(); } public static Document newDocument() throws Exception { DocumentBuilder parser = dbFactory.newDocumentBuilder(); return parser.newDocument(); } }