Here you can find the source of getTextList(Element elem, String name)
public static List<String> getTextList(Element elem, String name)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static List<String> getTextList(Element elem, String name) { List<String> result = new ArrayList<String>(); List<Element> childElements = getChildElementsByTagName(elem, name); for (Element childElem : childElements) { Node node = childElem.getFirstChild(); result.add(node == null ? "" : node.getTextContent()); }//www .j av a 2s . c om return result; } public static List<Element> getChildElementsByTagName(Element elem, String name) { List<Element> result = new ArrayList<Element>(); NodeList nodeList = elem.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(name)) { result.add((Element) child); } } return result; } }