Java XML Document Create createDocument()

Here you can find the source of createDocument()

Description

create Document

License

Creative Commons License

Declaration

public static Document createDocument() 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

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

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    public static Document createDocument() {
        Document doc = null;//from ww  w .j  a va  2s . c o m
        try {
            DocumentBuilderFactory docFactory = DocumentBuilderFactory
                    .newInstance();
            DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
            doc = docBuilder.newDocument();

            Element element = doc.getDocumentElement();
            // do i actually need to do this here? why?
            if (element != null)
                element.normalize();
        } catch (Throwable t) {
            t.printStackTrace();
        }

        return doc;
    }
}

Related

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