Java Utililty Methods XML Element Child Append

List of utility methods to do XML Element Child Append

Description

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

Method

voidappendChild(Document doc, Element parentElement, String elementName, String elementValue)
Add a child element to a parent element
appendChild(doc, parentElement, elementName, elementValue, null);
voidappendChild(Document doc, Element parentElement, String elementName, String elementValue)
Add a child element to a parent element
Element child = doc.createElement(elementName);
Text text = doc.createTextNode(elementValue);
child.appendChild(text);
parentElement.appendChild(child);
voidappendChild(Document doc, Node parentNode, String childName, String childContents)
append Child
if (childContents == null)
    throw (new NullPointerException("ChildNode is null."));
Element child = doc.createElement(childName);
child.setTextContent(childContents);
parentNode.appendChild(child);
voidappendChild(Document document, Node root, String name, String value)
append Child
Node node = document.createElement(name);
node.appendChild(document.createTextNode(value != null ? value : ""));
root.appendChild(node);
return;
ElementappendChildElement(Document doc, Element parent, Element child)
append a child element

Node whitespaceText = doc.createTextNode("\n");
parent.appendChild(whitespaceText);
parent.appendChild(child);
return child;
voidappendChildElement(Element parent, Element el, String[] order)
Append a child element to the parent at the specified location.
List<String> l = Arrays.asList(order);
int index = l.indexOf(el.getLocalName());
if (index == -1) {
    throw new IllegalArgumentException(
            "new child element '" + el.getLocalName() + "' not specified in order " + l); 
List<Element> elements = findSubElements(parent);
Element insertBefore = null;
...
ElementappendChildElement(Element parentNode, String nodeName)
append Child Element
Document doc = parentNode.getOwnerDocument();
Element childNode = doc.createElement(nodeName);
parentNode.appendChild(childNode);
return childNode;
ElementappendChildElement(final Element parentElement, final String name, final String value)
Appends a child element to the provided parent element.
Document parentDocument = parentElement.getOwnerDocument();
Element createElement = createElement(parentDocument, name);
if (value != null) {
    createElement.appendChild(parentDocument.createTextNode(value));
parentElement.appendChild(createElement);
return createElement;
ElementappendChildElementBoolean(Element parentNode, String tagName, boolean content)
append Child Element Boolean
Element elem = appendChildElement(parentNode, tagName);
setBooleanContent(elem, content);
return elem;
ElementappendChildElmt(Element aElmt, String aChildName)
append Child Elmt
Element wChild = aElmt.getOwnerDocument().createElement(aChildName);
aElmt.appendChild(wChild);
return wChild;