Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; public class Main { /** The Constant NS_PIPELINE_DATA. */ public static final String NS_PIPELINE_DATA = "http://www.daisy.org/ns/pipeline/data"; /** * Creates the dom. * * @param documentElementName * the document element name * @return the document */ public static Document createDom(String documentElementName) { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); DOMImplementation domImpl = documentBuilder.getDOMImplementation(); Document document = domImpl.createDocument(NS_PIPELINE_DATA, documentElementName, null); return document; } catch (ParserConfigurationException e) { e.printStackTrace(); return null; } } }