Here you can find the source of getText(Element elem)
public static String getText(Element elem)
//package com.java2s; /* /* w w w . jav a2s . co m*/ * XMLUtils.java * * Copyright (C) August Mayer, 2001-2004. All rights reserved. * Please consult the Boone LICENSE file for additional rights granted to you. * * Created on 09. Dezember 2002, 16:31 */ import org.w3c.dom.*; public class Main { /** * Extract the text in an element. * Concats data of Text and CDATASection elements. */ public static String getText(Element elem) { StringBuffer text = new StringBuffer(); NodeList l = elem.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { Node n = l.item(i); if (n instanceof Text) text.append(((Text) n).getData()); else if (n instanceof CDATASection) text.append(((CDATASection) n).getData()); } return text.toString(); } }