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

booleanaddElement(final Document document, final Element root, final String elementValue, final String elementName)
add Element
if (isEmpty(elementValue)) {
    return false;
Element element = document.createElement(elementName);
element.appendChild(document.createTextNode(elementValue));
root.appendChild(element);
return true;
ElementaddElement(final Document dom, final Element el, final String name, final String value)
add Element
Element newElement = dom.createElement(name);
newElement.appendChild(dom.createTextNode(value));
el.appendChild(newElement);
return el;
ElementaddElementAndSetContent(Document doc, String name, Element parent, String text)
add Element And Set Content
Element ee = addElement(doc, name, parent);
ee.setTextContent(text);
return ee;
ElementaddElementChildToElement(Document doc, Element parent, String elementName)
Adds an element to another of a document in memory
(It's supposed that the parent is one element of the document)
Element element = doc.createElement(elementName);
parent.appendChild(element);
return element;
ElementaddElementWithText(Document document, Element parentElement, String newElementName, String textString)
Creates a new element, with the given text inside that element.
Element newElement = document.createElement(newElementName);
Text text = document.createTextNode(textString);
newElement.appendChild(text);
parentElement.appendChild(newElement);
return newElement;
voidappendDateNode(Document owner, Element appendElement, String name, Date date)
append Date Node
Element dateElem = owner.createElement(name);
appendElement.appendChild(dateElem);
appendSingleValElement(owner, dateElem, "month", Integer.toString(date.getMonth() + 1));
appendSingleValElement(owner, dateElem, "day", Integer.toString(date.getDate()));
appendSingleValElement(owner, dateElem, "year", Integer.toString(date.getYear() + 1900));
appendSingleValElement(owner, dateElem, "hour", Integer.toString(date.getHours()));
appendSingleValElement(owner, dateElem, "minute", Integer.toString(date.getMinutes()));
appendSingleValElement(owner, dateElem, "second", Integer.toString(date.getSeconds()));
...
ElementcreateAndAppendChild(Element parentElement, String elementName, Properties attributes)
create And Append Child
Element element = createElement(parentElement.getOwnerDocument(), elementName, attributes);
parentElement.appendChild(element);
return element;
NodecreateChild(Document document, Node parent, String childNodeName)
create Child
return createChildInternal(document, parent, childNodeName);
ElementcreateChild(Element el, String name, boolean attach)
Creates an element with the given name in the specified element's DOM, inserting it into the tree structure as a child of that element if the attach flag is set.
Element child = el.getOwnerDocument().createElement(name);
if (attach)
    el.appendChild(child);
return child;
ElementcreateChild(final Element el, final String name)
Appends a child element with the given name to the specified DOM element.
final Element child = el.getOwnerDocument().createElement(name);
el.appendChild(child);
return child;