Java XML Document Create newXmlDocument()

Here you can find the source of newXmlDocument()

Description

Factory method to create a new XML document object.

License

Apache License

Declaration

public static final Document newXmlDocument() throws Exception 

Method Source Code

//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 {
    /**/*from w w w. j  a  v a 2 s  .co m*/
     * Factory method to create a new XML document object.
     * @return
     */
    public static final Document newXmlDocument() throws Exception {

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder builder = dbf.newDocumentBuilder();
        Document xmlDocument = builder.newDocument();

        return xmlDocument;
    }
}

Related

  1. newDocument()
  2. newDocument(boolean isNamespaceAware, boolean isValidating)
  3. newDocument(File file)
  4. newDocument(String namespaceURI, String qualifiedName)
  5. newDocument(String rootName)
  6. newXmlDocument()
  7. newXMLDocument()
  8. newXMLDocument()
  9. string2Document(final String xml)