Here you can find the source of addChildElement(Document doc, Node parent, String tag)
public static Element addChildElement(Document doc, Node parent, String tag)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.*; public class Main { /** Add an Element to a Document */ public static Element addChildElement(Document doc, Node parent, String tag) { Element e = doc.createElement(tag); doc.importNode(e, true);/*from ww w .ja va 2 s . c o m*/ parent.appendChild(e); return e; } }