Here you can find the source of getTextContent(Node node)
static String getTextContent(Node node)
//package com.java2s; /* it under the terms of the GNU General Public License as published by */ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { static String getTextContent(Node node) { NodeList list = node.getChildNodes(); String text = ""; int count = 0; for (int i = 0; list != null && i < list.getLength(); i++) { String value = list.item(i).getNodeValue(); if (value != null) { text += value;/* ww w.j a v a 2 s. c o m*/ count++; } } if (count == 0) { return null; } return text; } }