Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// under the terms of the GNU General Public License as published by the

import org.w3c.dom.*;

import javax.xml.parsers.*;

public class Main {
    public static Document CreateDom() {
        Document newdoc = getDocumentBuilder().newDocument();
        //newdoc..PreserveWhitespace = true;
        Element childnode = newdoc.createElement("root");
        newdoc.appendChild(childnode);
        return newdoc;
    }

    static DocumentBuilder getDocumentBuilder() {
        DocumentBuilder documentBuilder = null;
        try {
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilder = documentBuilderFactory.newDocumentBuilder();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return documentBuilder;
    }
}