Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getDirectTextContent(Node aNode) { String result = ""; NodeList nodeList = aNode.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node aSubNode = nodeList.item(i); if (aSubNode.getNodeType() == Node.TEXT_NODE) { result += aSubNode.getNodeValue(); } } return result; } }