Java XML Document Create createDocument()

Here you can find the source of createDocument()

Description

Creation of a XML DOM document.

License

Open Source License

Return

XML DOM Document object, or \b null in the case of failure

Declaration

public static Document createDocument() 

Method Source Code


//package com.java2s;
// Published under GNU General Public License conditions.

import javax.xml.parsers.*;
import org.w3c.dom.*;

public class Main {
    /**/*www .  jav  a 2  s .  c  o  m*/
     * Creation of a XML DOM document.
     *
     * This is a convenience method which returns an XML document
     * without any danger of throwing an exception.
     * All exceptions are converted to \b null values.
     *
     * @return XML DOM Document object, or \b null in the case of failure
     */
    public static Document createDocument() {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = null;

        try {
            builder = factory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            System.out.println("!!! DOM creation exception");
            System.out.println(e.toString());
        }

        Document doc = builder.newDocument();

        return doc;
    }
}

Related

  1. createDocument()
  2. createDocument()
  3. createDocument()
  4. createDocument()
  5. createDocument()
  6. createDocument()
  7. CreateDocument()
  8. createDocument()
  9. createDocument()