Java Utililty Methods XML Text Node Create

List of utility methods to do XML Text Node Create

Description

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

Method

TextcreateTextNode(Document doc, Calendar cal, boolean dateOnly)
Creates a Text node for converting a Calendar object into a string of XML timeInstant type or XML date type.
if (dateOnly) {
    return doc.createTextNode(xmlShortDateFormat.format(cal.getTime()));
} else {
    return doc.createTextNode(xmlDateFormat.format(cal.getTime()));
ElementcreateTextNode(Document doc, String elemName, String attrName, String attrValue, String content)
Creates node with given name appended by text node with content.
Element element = doc.createElement(elemName);
if (attrName != null && attrValue != null) {
    element.setAttribute(attrName, attrValue);
Text text = doc.createTextNode(content);
element.appendChild(text);
return element;
NodecreateTextNode(Document doc, String string)
create Text Node
return doc.createTextNode(string);
voidcreateTextNode(Element element, String nodeName, String textValue)
create Text Node
Document doc = element.getOwnerDocument();
Node resourceNameNode = doc.createElementNS(NAMESPACE_URI, nodeName);
element.appendChild(resourceNameNode);
Text resourceNameText = doc.createTextNode(textValue);
resourceNameNode.appendChild(resourceNameText);
ElementcreateTextNode(Node doc, String elementName, String elementText)
Easily creates a new Node, containing Text and returns the new created Node.
Element elm = doc.getOwnerDocument().createElement(elementName);
Text elmTxt = doc.getOwnerDocument().createTextNode(elementText);
elm.appendChild(elmTxt);
doc.appendChild(elm);
return elm;
TextcreateTextNode(Node node, String data)
create Text Node
return createTextNode(node.getOwnerDocument(), data);
TextextractOrCreateTextNode(Element filenameElement, String defaultText)
extract Or Create Text Node
Document rootDoc = filenameElement.getOwnerDocument();
if (filenameElement.getChildNodes().item(0) instanceof Text) {
    return (Text) filenameElement.getChildNodes().item(0);
Text textNode = rootDoc.createTextNode(defaultText);
filenameElement.appendChild(textNode);
return textNode;
NodegetFirstNodeFromPath(Node contextNode, final String[] path, final boolean create)
Use a path to select the first occurence of a node.
if (contextNode == null || path == null || path.length == 0)
    return contextNode;
Node item = getFirstNodeFromPath(contextNode, path, 0);
if (item == null && create == true) {
    int i = 0;
    NodeList childs;
    boolean found;
    int m, l;
...