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 {
    /**
     * Inserts a new value for an XML tag specified by <code>tagName</code> name
     * in a <code>Document</code> object.
     * 
     * @param doc
     *            Document object.
     * @param tagName
     *            Name of the tag as String.
     * @param tagValue
     *            Value of the tag as String.
     */
    public static Element insertTagValue(Document doc, String tagName, String tagValue) {
        Element element = doc.createElement(tagName);
        doc.getDocumentElement().appendChild(element);
        if (tagValue != null) {
            element.appendChild(doc.createTextNode(tagValue));
        }
        return element;
    }
}