Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.parsers.*;

import org.w3c.dom.*;

public class Main {
    /** Creates a new XML document.
     *
     * @param namespace the default namespace of the document
     * @param documentElement the name of the document element
     * @return a new XML document
     */
    public static Document createDocument(String namespace, String documentElement) {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            DOMImplementation impl = builder.getDOMImplementation();
            return impl.createDocument(namespace, documentElement, null);
        } catch (ParserConfigurationException e) {
            // This exception is never thrown, treat as fatal if it is
            throw new RuntimeException(e);
        }
    }
}