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 { public synchronized static Document createDocument() throws ParserConfigurationException { DocumentBuilder builder = createDocumentBuilder(); if (builder == null) return null; return builder.newDocument(); } public synchronized static DocumentBuilder createDocumentBuilder() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); return factory.newDocumentBuilder(); } }