Here you can find the source of getTextNodeValue(Node node)
public static String getTextNodeValue(Node node) throws Exception
//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 ""; } }