Java XML DocumentBuilder Create getDocumentBuilder()

Here you can find the source of getDocumentBuilder()

Description

Returns a DocumentBuilder, which is used for parsing XML documents.

License

Artistic License

Return

a DocumentBuilder which is used for parsing XML documents. Never null.

Declaration

public static DocumentBuilder getDocumentBuilder() 

Method Source Code

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

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

public class Main {
    /**/*from w w w.ja v a 2 s.  com*/
     * Returns a <code>DocumentBuilder</code>, which is used for parsing XML
     * documents.
     *
     * @return a <code>DocumentBuilder</code> which is used for parsing XML
     *         documents. Never <code>null</code>.
     */
    public static DocumentBuilder getDocumentBuilder() {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            dbf.setValidating(false);

            return dbf.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
}

Related

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