Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;

public class Main {
    /**
     * This method creates an empty <code>Document</code> object that can be used to store
     * data that will later be written out as an XML file.  It is adapted from 
     * code posted at 
     * <a href="http://www.exampledepot.com/egs/javax.xml.parsers/CreateDom.html"
     *    target="_top">
     * http://www.exampledepot.com/egs/javax.xml.parsers/CreateDom.html</a>.
     * @return an empty <code>Document</code> object
     * @see http://www.exampledepot.com/egs/javax.xml.parsers/CreateDom.html
     */
    public static Document createDomDocument() {
        try {
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document localDoc = builder.newDocument();
            return localDoc;
        } catch (ParserConfigurationException pce) {
            System.err.println(pce);
        }
        return null;
    }
}