Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    /**
     * Adds an element to the specified document.
     * @param doc the document.
     * @param parent the parent node.
     * @param name the element name.
     * @return the element.
     */
    public static Element addElement(final Document doc, final Node parent, final String name) {
        Element element = doc.createElement(name);
        if (parent != null) {
            parent.appendChild(element);
        } else {
            doc.appendChild(element);
        }
        return element;
    }
}