Java tutorial
//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() + " "; } } return text; } }