Here you can find the source of addElement(Element parent, Element childElement)
public static Element addElement(Element parent, Element childElement)
//package com.java2s; /*/*w w w . j av a 2s. co m*/ * JFox - The most lightweight Java EE Application Server! * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn. * * JFox is licenced and re-distributable under GNU LGPL. */ import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element addElement(Node parent, String name, Attr[] attrs) { Element element; if (parent instanceof Document) { element = ((Document) parent).createElement(name); } else { element = parent.getOwnerDocument().createElement(name); } if (attrs != null && attrs.length > 0) { for (Attr attr : attrs) { element.setAttributeNode(attr); } } parent.appendChild(element); return element; } public static Element addElement(Element parent, Element childElement) { Node childNode = parent.getOwnerDocument().importNode(childElement, true); parent.appendChild(childNode); return parent; } }