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

ElementaddChildElement(Element parentElement, String elementName)
add Child Element
Element childElement = parentElement.getOwnerDocument().createElement(elementName);
parentElement.appendChild(childElement);
return childElement;
ElementaddChildElement(Element parentElement, String elementName)
add Child Element
Element childElement = parentElement.getOwnerDocument().createElement(elementName);
parentElement.appendChild(childElement);
return childElement;
ElementaddChildElement(Element root, Element element, String name)
add Child Element
String safeName = name.replaceAll("\\$", "::");
Element child = getNewElement(root, safeName);
element.appendChild(child);
return child;
ElementaddChildElement(Node element, String name, String[][] attributes)
add Child Element
return addChildElement(element, name, null, attributes);
ElementaddChildElement(Node parent, String elementName, String textContent)
add Child Element
Element element = addChildElement(parent, elementName);
element.setTextContent(textContent);
return element;
ElementaddChildElement(Node parent, String tag, String value)
Adds a Child element to the parent node.
Document doc = (parent.getNodeType() == Node.DOCUMENT_NODE) ? (Document) parent : parent.getOwnerDocument();
Element child = doc.createElement(tag);
if (value != null)
    child.appendChild(doc.createTextNode(value));
parent.appendChild(child);
return child;
voidaddChildElements(Node n, List elements)
add Child Elements
NodeList nl = n.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
    n = nl.item(i);
    if (n.getNodeType() != 1) {
        continue;
    } else {
        if (hasChild(n)) {
            addChildElements(n, elements);
...
NodeaddChildNode(Node pNode, String name, String value)
add Child Node
Document _doc = null;
if (pNode.getNodeType() == Node.DOCUMENT_NODE) {
    _doc = (Document) pNode;
} else {
    _doc = pNode.getOwnerDocument();
Element _ele = _doc.createElement(name);
Node _node = _doc.createTextNode(value);
...
voidaddChildren(Element element, List children)
Append the given list of children Elements to the given Element.
for (int i = 0; i < children.size(); i++) {
    element.appendChild((Element) children.get(i));
voidaddElement(Element parent, Element child)
Add the child node to parent
parent.appendChild(child);