import org.w3c.dom.Element; import org.w3c.dom.Node; public class Utils { public static String getElementText(Element e) { StringBuffer buf = new StringBuffer(); for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) { if (n.getNodeType() == Node.TEXT_NODE || n.getNodeType() == Node.CDATA_SECTION_NODE) { buf.append(n.getNodeValue()); } } return buf.toString(); } }