Here you can find the source of getTextContentOfElements(Element elem, String tagName)
public static List<String> getTextContentOfElements(Element elem, String tagName)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static List<String> getTextContentOfElements(Element elem, String tagName) { List<String> result = new ArrayList<String>(); NodeList inputElems = elem.getElementsByTagName(tagName); for (int i = 0; i < inputElems.getLength(); i++) { Element childElem = (Element) inputElems.item(i); result.add(childElem.getTextContent()); }/*from w w w . j a v a2s . c o m*/ return result; } }