Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.*;

public class Main {
    public static final String XML_DOCUMENT_IMPL = "org.apache.xerces.dom.DocumentImpl";

    /**
     * createXMLDoc(String) Given a name for the root element will create and
     * return a org.w3c.dom.Document with the root node specified. The Document
     * will be based on the Document implementation as specified in the system
     * properties file XML_DOCUMENT_CLASS
     * 
     * @param String
     *            rootName
     * @return Document
     * @author Peter Manta (after blatant copying of Jeff)
     */
    public static org.w3c.dom.Document createXMLDoc(String rootName) {
        Class docClass = null;
        Document doc = null;
        Element root = null;
        try {
            docClass = Class.forName(XML_DOCUMENT_IMPL);
            doc = (Document) docClass.newInstance();
            root = doc.createElement(rootName);
            doc.appendChild(root);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
        return doc;
    }
}