Here you can find the source of getNodeText(Node node)
public static String getNodeText(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 getNodeText(Node node) { if (node == null) { return null; }//from ww w .ja v a 2 s.c o m String result = ""; NodeList childList = node.getChildNodes(); for (int i = 0; i < childList.getLength(); ++i) { Node child = childList.item(i); if (child.getNodeName().equals("#text")) { result = result + child.getNodeValue(); } else { result = result + getNodeText(child); } } return result; } }