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

ElementaddChild(Document doc, Node parent, String name)
add Child
Element child = doc.createElement(name);
parent.appendChild(child);
return child;
voidaddChild(final Document doc, Element parent, final String childName, final String childValue)
add Child
Element child = doc.createElement(childName);
Text text = doc.createTextNode(childValue);
child.appendChild(text);
parent.appendChild(child);
ElementaddChildElement(Document doc, Node parent, String tag)
Add an Element to a Document
Element e = doc.createElement(tag);
doc.importNode(e, true);
parent.appendChild(e);
return e;
ElementaddChildElement(Document document, String elementName, Node parentNode)
Utility method to add an attribute to a given element
Element elt = document.createElement(elementName);
parentNode.appendChild(elt);
return elt;
ElementaddChildElement(Element element, String childElementName, Document document)
Creates a child element with the given name and appends it to the element child node list.
Element newElement = document.createElement(childElementName);
element.appendChild(newElement);
return newElement;
ElementaddChildElementNSElement(Element element, String childElementName, Document document, String nameSpaceUrl)
Creates a child element with the given namespace supportive name and appends it to the element child node list.
Element newElement = document.createElementNS(nameSpaceUrl, childElementName);
element.appendChild(newElement);
return element;
ElementaddChildElementValue(Element element, String childElementName, String childElementValue, Document document)
Creates a child element with the given name and appends it to the element child node list.
Element newElement = addChildElement(element, childElementName, document);
newElement.appendChild(document.createTextNode(childElementValue));
return newElement;
ElementaddChildElementValue(Element element, String childElementName, String childElementValue, Document document)
Creates a child element with the given name and appends it to the element child node list.
Element newElement = addChildElement(element, childElementName, document);
newElement.appendChild(document.createTextNode(childElementValue));
return newElement;
booleanaddChildEpcList(final Document document, final Element root, final String childEPCs)
Adds the EPCs from the given list of childEPCs as elements inside an element to the XML document.
if (isEmpty(childEPCs)) {
    return false;
Element element = document.createElement("childEPCs");
StringTokenizer st = new StringTokenizer(childEPCs);
while (st.hasMoreTokens()) {
    addElement(document, element, st.nextToken(), "epc");
root.appendChild(element);
return true;
NodeaddChildNode(Document doc, Node parentNode, String childName, String childValue)
Add a child node
if (doc == null || parentNode == null || childName == null) {
    return null;
Node childNode = doc.createElement(childName);
if (childValue != null) {
    childNode.setTextContent(childValue);
parentNode.appendChild(childNode);
...