Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static final String getText(Node node) { if (node.hasChildNodes()) { NodeList childNodes = node.getChildNodes(); if (childNodes.getLength() > 0) { Node child = childNodes.item(0); if ((child.getNodeType() == Node.CDATA_SECTION_NODE) || (child.getNodeType() == Node.TEXT_NODE)) { return child.getNodeValue(); } } } return null; } }