Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /** * Create a node with tag name. * * @param document * the document * @param parent * the parent node * @param tagName * the tag name * @return the created node */ public static Element createNode(Document document, Node parent, String tagName) { Element node = document.createElement(tagName); parent.appendChild(node); return node; } }