Java XML Document Create getNewDocument()

Here you can find the source of getNewDocument()

Description

get New Document

License

Apache License

Declaration

public static Document getNewDocument() throws ParserConfigurationException 

Method Source Code


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

import org.w3c.dom.Document;

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

public class Main {
    public static Document getNewDocument() throws ParserConfigurationException {
        return getNewDocument(false);
    }//from  w w  w.  j a va 2  s  . c  o m

    public static Document getNewDocument(Boolean nameSpaceAwareness) throws ParserConfigurationException {
        DocumentBuilder builder = getDocumentBuilder(false);
        return builder.newDocument();
    }

    private static DocumentBuilder getDocumentBuilder(boolean NamespaceAwareness)
            throws ParserConfigurationException {
        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        domFactory.setNamespaceAware(NamespaceAwareness);
        //domFactory.setValidating(true);
        //domFactory.setIgnoringElementContentWhitespace( true );
        domFactory.setAttribute("http://apache.org/xml/features/dom/include-ignorable-whitespace", Boolean.FALSE);

        return domFactory.newDocumentBuilder();
    }
}

Related

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