Here you can find the source of addElementText(Node test, List holder)
protected static void addElementText(Node test, List holder)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; import java.util.*; public class Main { protected static void addElementText(Node test, List holder) { int Type = test.getNodeType(); switch (Type) { case Node.CDATA_SECTION_NODE: case Node.TEXT_NODE: String text = test.getNodeValue(); if (isAlphaString(text)) holder.add(text);//from ww w . j ava 2s . c o m return; case Node.ELEMENT_NODE: accumulateElementText((Element) test, holder); default: Type = 0; } } public static boolean isAlphaString(String s) { if (s == null) return (false); for (int i = 0; i < s.length(); i++) { if (Character.isLetterOrDigit(s.charAt(i))) return (true); } return (false); } /** retrieve all Strings from this node */ public static void accumulateElementText(Element doc, List holder) { NodeList nodes = doc.getChildNodes(); int n = nodes.getLength(); for (int i = 0; i < n; i++) { addElementText(nodes.item(i), holder); } } }