Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Returns the text value of the specified node. The returned value is the node value of the first child of <code>node</code> which type * is <code>Document.TEXT_NODE</code>. * * @param node * the node which text value has to be retrieved. * @return the text value of the node. */ public static String getTextValue(Node node) { NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i).getNodeType() == Document.TEXT_NODE) { return list.item(i).getNodeValue(); } } return null; } }