Java examples for XML:DOM Document
create Empty XML Document
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.DOMImplementation; public class Main { public static Document createEmptyDoc(String top) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance();/*from w ww .ja v a2 s . c om*/ DocumentBuilder builder = factory.newDocumentBuilder(); DOMImplementation impl = builder.getDOMImplementation(); return impl.createDocument(null, top, null); } }