Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { /** * Creates an element with the specified tag and appends it to the element supplied * @param element - the element to add the created element to * @param tag - the tag name for the element to create * @return The element created */ public static Element appendElement(Element element, String tag) { Document document = element.getOwnerDocument(); Element childElement = document.createElement(tag); element.appendChild(childElement); return childElement; } }