Java Utililty Methods XML Child Element Create

List of utility methods to do XML Child Element Create

Description

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

Method

ElementcreateChild(Node node, String elemName)
Creates a new Node-object with the specified name and appends it as a child element to the provided Node- parameter.
if (node == null || elemName == null || "".equals(elemName))
    throw new IllegalArgumentException("Arguments are not allowed to be null or empty");
Document document = null;
if (node instanceof Document) {
    document = (Document) node;
} else if (node.getOwnerDocument() != null) {
    document = node.getOwnerDocument();
Element newChild = null;
if (document != null) {
    newChild = document.createElement(elemName);
    node.appendChild(newChild);
return newChild;
ElementcreateChildElement(Document doc, Element parent, String name)
This method is used to create a Child element.
Element newElem = doc.createElement(name);
parent.appendChild(newElem);
return newElem;
ElementcreateChildElement(Document doc, Node node, String nodeName)
Create a child of the given node.
Element element = doc.createElement(nodeName);
node.appendChild(element);
return element;
ElementcreateChildElement(Element parent, String name)
Creates a named Element and appends it to the given element, returns it.
Document doc = parent.getOwnerDocument();
Element e = doc.createElement(name);
parent.appendChild(e);
return e;
ElementcreateChildElement(Element parentElement, String elementName)
create Child Element
Element child = parentElement.getOwnerDocument().createElement(elementName);
parentElement.appendChild(child);
return child;
ElementcreateChildElement(Element parentElement, String strTagName)
create Child Element
Element eleChildElement = parentElement.getOwnerDocument().createElement(strTagName);
parentElement.appendChild(eleChildElement);
return eleChildElement;
ElementcreateChildElement(final String tagName, final Node parent, final Document document)
Creates a child element with the given name and parent.
final Element child = document.createElement(tagName);
parent.appendChild(child);
return child;
ElementcreateChildElement(String tagName, Element parentElement)
create Child Element
Element result = parentElement.getOwnerDocument().createElement(tagName);
parentElement.appendChild(result);
return result;
ElementcreateTextChild(Node elem, String elemName, Boolean text)
create Text Child
return createTextChild(elem, elemName, text == null ? "false" : text.toString());
ElementgetChildElementByChain(Element element, String[] chain, boolean create)
Returns the element which is at the end of the specified chain ...
if (chain == null)
    return null;
Element e = element;
for (int i = 0; i < chain.length; i++) {
    if (e == null)
        return null;
    e = getChildElementByTagName(e, chain[i]);
return e;