Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*L
 *  Copyright SAIC, Ellumen and RSNA (CTP)
 *
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/national-biomedical-image-archive/LICENSE.txt for details.
 */

import javax.xml.parsers.*;

import org.w3c.dom.*;

public class Main {
    private static Element constructDocument() throws Exception {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.newDocument();
        Element rootElement = doc.createElement("root");
        doc.appendChild(rootElement);
        Element c1Element = doc.createElement("c1");
        Element c2Element = doc.createElement("c2");
        Element c3Element = doc.createElement("c3");
        Element gc1Element = doc.createElement("gc1_1");
        Element gc2Element = doc.createElement("gc1_2");
        Text textNode = doc.createTextNode("uncle_freddie");
        Element gc3Element = doc.createElement("gc2_1");

        rootElement.appendChild(c1Element);
        rootElement.appendChild(c2Element);
        rootElement.appendChild(c3Element);

        c1Element.appendChild(gc1Element);
        c1Element.appendChild(gc2Element);
        c2Element.appendChild(gc3Element);

        gc3Element.appendChild(textNode);

        return rootElement;
    }
}