Here you can find the source of addChildElement(Element root, Element element, String name)
public static Element addChildElement(Element root, Element element, String name)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; public class Main { public static Element addChildElement(Element root, Element element, String name) { String safeName = name.replaceAll("\\$", "::"); Element child = getNewElement(root, safeName); element.appendChild(child);/* ww w . jav a2 s . c om*/ return child; } public static Element getNewElement(Element element, String name) { String safeName = name.replaceAll("\\$", "::"); return element.getOwnerDocument().createElement(safeName); } }