Java Utililty Methods XML Child Element Add

List of utility methods to do XML Child Element Add

Description

The list of methods to do XML Child Element Add are organized into topic(s).

Method

voidaddAsFirstChild(Element element, Element newChild)
add As First Child
if (element.hasChildNodes()) {
    element.insertBefore(newChild, element.getChildNodes().item(0));
} else {
    element.appendChild(newChild);
ElementAddChild(Element parent, String nodename)
Add Child
Element childnode = parent.getOwnerDocument().createElement(nodename);
parent.appendChild(childnode);
return childnode;
voidaddChild(final Node node, final Node child)
add Child
if (node != null) {
    node.appendChild(child);
voidaddChild(Node parent, Node child)
add Child
parent.appendChild(child);
voidaddChild(Node parent, String name, String text)
Utility method for adding text nodes.
Element child = parent.getOwnerDocument().createElement(name);
child.appendChild(parent.getOwnerDocument().createTextNode(text));
parent.appendChild(child);
NodeaddChild(Node parent, String namespaceURI, String childName)
add Child
final Element child = parent.getOwnerDocument().createElementNS(namespaceURI, childName);
return parent.appendChild(child);
voidaddChildElement(Element element, String name, Object textValue)
Adds the child element with the given text
Document document = element.getOwnerDocument();
Element child = document.createElement(name);
element.appendChild(child);
if (textValue != null) {
    String text = textValue.toString();
    child.appendChild(document.createTextNode(text));
ElementaddChildElement(Element element, String name, String text)
add Child Element
Document document = element.getOwnerDocument();
Element result = (Element) element.appendChild(document.createElement(name));
if (text != null) {
    result.appendChild(document.createTextNode(text));
return result;
ElementaddChildElement(Element element, String name, String text)
add Child Element
Document document = element.getOwnerDocument();
Element result = (Element) element.appendChild(document.createElement(name));
if (text != null)
    result.appendChild(document.createTextNode(text));
return result;
ElementaddChildElement(Element element, String name, String text)
add Child Element
Document document = element.getOwnerDocument();
Element result = (Element) element.appendChild(document.createElement(name));
if (text != null)
    result.appendChild(document.createTextNode(text));
return result;