Here you can find the source of getTextContent(org.w3c.dom.Node element)
public static String getTextContent(org.w3c.dom.Node element)
//package com.java2s; /*/*from www.j av a 2 s . c o m*/ * Helma License Notice * * The contents of this file are subject to the Helma License * Version 2.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://adele.helma.org/download/helma/license.txt * * Copyright 1998-2003 Helma Software. All Rights Reserved. * * $RCSfile$ * $Author$ * $Revision$ * $Date$ */ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * return the text content of an element */ public static String getTextContent(org.w3c.dom.Node element) { StringBuffer childtext = new StringBuffer(); NodeList childlist = element.getChildNodes(); int ct = childlist.getLength(); for (int j = 0; j < ct; j++) { org.w3c.dom.Node childNode = childlist.item(j); if ((childNode.getNodeType() == Node.TEXT_NODE) || (childNode.getNodeType() == Node.CDATA_SECTION_NODE)) { childtext.append(childNode.getNodeValue().trim()); } } return childtext.toString(); } }