Android XML Node Value Get getTextNodeValue(Node node)

Here you can find the source of getTextNodeValue(Node node)

Description

get Text Node Value

Declaration

public static String getTextNodeValue(Node node) throws Exception 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static String getTextNodeValue(Node node) throws Exception {
        Node child;/*from  w w w  .  java 2  s .c o  m*/
        if (node != null) {
            if (node.hasChildNodes()) {
                child = node.getFirstChild();
                while (child != null) {
                    if (child.getNodeType() == Node.TEXT_NODE) {
                        return child.getNodeValue();
                    }
                    child = child.getNextSibling();
                }
            }
        }
        return "";
    }
}

Related

  1. getText(Node node, String tag)
  2. getTextContent(Node n)
  3. getTextContent(Node n)
  4. getTextContent(Node n, StringBuffer buf)
  5. getTextContent(org.w3c.dom.Node element)
  6. getXml(Node node)
  7. getXmlInt(Node node, String xmlLocalName, int defaultValue)
  8. getXmlLong(Node node, String xmlLocalName, long defaultValue)
  9. getXmlString(Node node, String xmlLocalName)