Java tutorial
//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>Element</code> object. * * @param elementToAppend * Element object. * @param tagName * Name of the tag as String. * @param tagValue * Value of the tag as String. */ public static Element insertTagInElement(Document document, Element elementToAppend, String tagName, String tagValue) { Element newElement = document.createElement(tagName); elementToAppend.appendChild(newElement); newElement.appendChild(document.createTextNode(tagValue)); return newElement; } }