Here you can find the source of appendElement(Node parent, String name)
public static Element appendElement(Node parent, String name)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element appendElement(Node parent, String name) { return appendElement(parent, name, null); }//from w ww. j a v a2s .c om public static Element appendElement(Node parent, String name, Object data, String... attributes) { Document doc = (parent.getNodeType() == Node.DOCUMENT_NODE) ? (Document) parent : parent.getOwnerDocument(); Element e = doc.createElement(name); parent.appendChild(e); if (data != null) e.appendChild(doc.createTextNode(data.toString())); for (int i = 0; i < attributes.length; ++i) e.setAttribute(attributes[i++], attributes[i]); return e; } }