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;

public class Main {
    private static final String DEFAULT_NAMESPACE = "http://www.epml.de";

    public static Element addElement(Element parent, String childName, Document doc) {
        Element childElement = doc.createElementNS(DEFAULT_NAMESPACE, childName);
        parent.appendChild(childElement);
        return childElement;
    }

    public static Element addElement(Element parent, String childName, String textValue, Document doc) {
        Element childElement = doc.createElementNS(DEFAULT_NAMESPACE, childName);
        childElement.setTextContent(textValue);
        parent.appendChild(childElement);
        return childElement;
    }

    public static Element addElement(Element parent, String childName, String attributeName, String attributeValue,
            Document doc) {
        Element childElement = doc.createElementNS(DEFAULT_NAMESPACE, childName);
        childElement.setAttribute(attributeName, attributeValue);
        parent.appendChild(childElement);
        return childElement;
    }
}