Here you can find the source of addElement(final Document doc, final Node parent, final String name)
Parameter | Description |
---|---|
doc | the document. |
parent | the parent node. |
name | the element name. |
public static Element addElement(final Document doc, final Node parent, final String name)
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**/*from w ww . ja v a 2 s. c om*/ * Adds an element to the specified document. * @param doc the document. * @param parent the parent node. * @param name the element name. * @return the element. */ public static Element addElement(final Document doc, final Node parent, final String name) { Element element = doc.createElement(name); if (parent != null) { parent.appendChild(element); } else { doc.appendChild(element); } return element; } }