Java XML Document Create newDocument()

Here you can find the source of newDocument()

Description

returns a new Empty XMl Document

License

LGPL

Exception

Parameter Description
ParserConfigurationException an exception
FactoryConfigurationError an exception

Return

new Document

Declaration

public static Document newDocument() throws ParserConfigurationException, FactoryConfigurationError 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

public class Main {
    private static DocumentBuilder docBuilder;

    /**/*from   w  w w  . j av  a2 s .  c  o m*/
     * returns a new Empty XMl Document
     * @return new Document
     * @throws ParserConfigurationException
     * @throws FactoryConfigurationError
     */
    public static Document newDocument() throws ParserConfigurationException, FactoryConfigurationError {
        if (docBuilder == null) {
            docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        }
        return docBuilder.newDocument();
    }
}

Related

  1. getDocument(String xslName)
  2. getDocument(URL location, boolean validating, boolean namespaceAware)
  3. getNewDocument()
  4. getNewDocument()
  5. getNewXmlDocument()
  6. newDocument()
  7. newDocument()
  8. newDocument()
  9. newDocument()