Example usage for javax.xml.parsers DocumentBuilder newDocument

List of usage examples for javax.xml.parsers DocumentBuilder newDocument

Introduction

In this page you can find the example usage for javax.xml.parsers DocumentBuilder newDocument.

Prototype


public abstract Document newDocument();

Source Link

Document

Obtain a new instance of a DOM Document object to build a DOM tree with.

Usage

From source file:Main.java

public static Document newDocument() {

    DocumentBuilder db = newDocumentBuilder();
    return db.newDocument();
}

From source file:Main.java

/**
 * Creates a new and empty XML document/*w w w  .  j  av  a 2 s . com*/
 * @return New XML document
 * @throws ParserConfigurationException
 */
public static Document createNewDocument() throws ParserConfigurationException {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);

    DocumentBuilder builder = dbf.newDocumentBuilder();
    return builder.newDocument();
}

From source file:Main.java

public static Document createDocument() throws Exception {
    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = builderFactory.newDocumentBuilder();
    return builder.newDocument();
}

From source file:Main.java

/**
 * createXmlDocumnet creates a new Document object using the JAXP API.
 * @return Document a DOM style Document object.
 * @throws ParserConfigurationException/*w w  w  . j a va 2  s  .com*/
 */
public static Document createXmlDocument() throws ParserConfigurationException {
    DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = fact.newDocumentBuilder();
    Document doc = db.newDocument();
    return (doc);
}

From source file:Main.java

/**
 * Uses the DocumentBuilderFactory to create a new doc and returns it
 *
 * @return Document object called doc//  w w w  .  ja va2 s.c o m
 */
public static Document createDoc() throws ParserConfigurationException {
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    return dBuilder.newDocument();
}

From source file:Main.java

public final static Document newDocument() throws ParserConfigurationException {
    DocumentBuilder bldr = getDocumentBuilder();
    return bldr.newDocument();
}

From source file:Main.java

/**
 * Creates a new XML document./*from   w  w  w.ja v a2 s .c om*/
 * @return the XML document
 */
public static Document createDocument() {
    try {
        DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = fact.newDocumentBuilder();
        return db.newDocument();
    } catch (ParserConfigurationException e) {
        //will probably never be thrown because we're not doing anything fancy with the configuration
        throw new RuntimeException(e);
    }
}

From source file:Main.java

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

From source file:Main.java

/**
 * Creates a new document//ww  w .j a  v a 2 s.c  o  m
 * 
 * @return the document
 * @throws Exception 
 */
public static Document createDocument() throws Exception {

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = dbf.newDocumentBuilder();
    return builder.newDocument();

}

From source file:Main.java

public static Document createDocument() throws ParserConfigurationException, IOException, SAXException {
    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    return dBuilder.newDocument();
}