Java examples for XML:DOM Element Create
create Element from tag name
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static Element createElement(Element element, String tagName) { return createElement(element, tagName, null); }//from w w w.ja v a 2 s. c o m public static Element createElement(Element element, String tagName, String text) { Document doc = element.getOwnerDocument(); Element child = doc.createElement(tagName); if (text != null) child.setTextContent(text); element.appendChild(child); return child; } }