Here you can find the source of getNodeValue(Node node)
public static String getNodeValue(Node node)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getNodeValue(Node node) { NodeList childNodes = node.getChildNodes(); for (int x = 0; x < childNodes.getLength(); x++) { Node data = childNodes.item(x); if (data.getNodeType() == Node.TEXT_NODE) return data.getNodeValue(); }/*from ww w . j a v a 2 s . c om*/ return ""; } public static String getNodeValue(String tagName, NodeList nodes) { for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeName().equalsIgnoreCase(tagName)) { NodeList childNodes = node.getChildNodes(); for (int y = 0; y < childNodes.getLength(); y++) { Node data = childNodes.item(y); if (data.getNodeType() == Node.TEXT_NODE) return data.getNodeValue(); } } } return ""; } }