Java Utililty Methods XML Node Value

List of utility methods to do XML Node Value

Description

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

Method

StringgetNodeValue(Node N)
Will find the value using getNodeValue or check for one CDATA child
if (N == null)
    return null;
if (N.getFirstChild() == null)
    return N.getNodeValue();
if (N.getNodeValue() != null)
    return N.getNodeValue();
Node[] Nds = SearchChildrenNodes(N, "#cdata-section", null);
if (Nds == null || Nds.length > 1)
...
StringgetNodeValue(Node n)
get Node Value
if (n == null)
    return null;
String val = n.getNodeValue();
if (val == null) {
    Node child = n.getFirstChild();
    if (child != null) {
        val = child.getNodeValue();
return val;
StringgetNodeValue(Node node)
Get the value of this node.
NodeList nodeList = node.getChildNodes();
int length = nodeList.getLength();
for (int i = 0; i < length; i++) {
    Node n = nodeList.item(i);
    if (n instanceof Text) {
        Text t = (Text) n;
        return t.getNodeValue();
return "";
StringgetNodeValue(Node node)
get Node Value
if (node == null) {
    return null;
if (node.getNodeType() == Node.ELEMENT_NODE) {
    return getElementText((Element) node);
} else if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE) {
    return getFragmentText((DocumentFragment) node);
} else {
...
StringgetNodeValue(Node node)
get Node Value
if (node == null)
    return null;
if (node.getNodeType() == Node.ELEMENT_NODE)
    return getElementText((Element) node);
else if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE)
    return getFragmentText((DocumentFragment) node);
else
    return node.getNodeValue();
...
StringgetNodeValue(Node node)
Returns value/cdata from xml node.
String value = node.getNodeValue();
if (value == null) {
    Node nChild = node.getFirstChild();
    if (nChild instanceof CharacterData) {
        CharacterData cd = (CharacterData) nChild;
        value = cd.getData();
return value;
StringgetNodeValue(Node node)
Gets the text value of a node.
String value = null;
if (node != null) {
    value = node.getNodeValue();
    if (value == null) {
        Node child = node.getFirstChild();
        if (child != null)
            value = child.getNodeValue();
    if (value != null) {
        value = value.trim();
        if (value.length() == 0)
            value = null;
return value;
StringgetNodeValue(Node node)
get Node Value
if (node == null)
    return null;
if (node.getNodeType() == Node.ELEMENT_NODE)
    return getElementText((Element) node);
else if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE)
    return getFragmentText((DocumentFragment) node);
else
    return node.getNodeValue();
...
StringgetNodeValue(Node node)
get Node Value
String value = null;
if (node != null) {
    value = node.getNodeValue();
    if (value == null) {
        value = node.getTextContent();
return value;
...
StringgetNodeValue(Node node)
Gets the node value
String value = null;
if (node.getFirstChild() != null) {
    value = node.getFirstChild().getNodeValue();
return value;