Java XML Document Create newDocument()

Here you can find the source of newDocument()

Description

Create a new blank XML document.

License

Open Source License

Exception

Parameter Description
IOException If there is an error creating the XML document.

Return

The new blank XML document.

Declaration

public static Document newDocument() throws IOException 

Method Source Code

//package com.java2s;

import java.io.IOException;

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

import org.w3c.dom.Document;

public class Main {
    /**/*w  ww  .  java  2s  . com*/
     * Create a new blank XML document.
     * 
     * @return The new blank XML document.
     * 
     * @throws IOException If there is an error creating the XML document.
     */
    public static Document newDocument() throws IOException {
        try {
            DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = builderFactory.newDocumentBuilder();
            return builder.newDocument();
        } catch (Exception e) {
            IOException thrown = new IOException(e.getMessage());
            throw thrown;
        }
    }
}

Related

  1. newDocument()
  2. newDocument()
  3. newDocument()
  4. newDocument()
  5. newDocument()
  6. newDocument()
  7. newDocument()
  8. newDocument()
  9. newDocument(boolean isNamespaceAware, boolean isValidating)