Here you can find the source of getText(Node node)
public static String getText(Node node)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.*; public class Main { public static String getText(Node node) { String text = ""; NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.TEXT_NODE) { text += child.getNodeValue() + " "; }/*from ww w . j a v a 2 s.c o m*/ } return text; } }