Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

import org.w3c.dom.Document;

public class Main {
    public static Document newDocument() {

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

    public static DocumentBuilder newDocumentBuilder() {
        return newDocumentBuilder(true);
    }

    public static DocumentBuilder newDocumentBuilder(boolean validating) {

        try {

            DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
            dbfac.setNamespaceAware(true);
            dbfac.setValidating(validating);

            return dbfac.newDocumentBuilder();

        } catch (ParserConfigurationException e) {
            throw new RuntimeException(e);
        }
    }
}