Here you can find the source of getTextValue(final Element elem)
public static String getTextValue(final Element elem)
//package com.java2s; //License from project: Open Source License import java.util.List; import org.w3c.dom.CharacterData; import org.w3c.dom.Comment; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import com.google.common.collect.Lists; public class Main { public static String getTextValue(final Element elem) { if (elem == null) { return null; }/*w ww. j a v a2 s . co m*/ final StringBuilder str = new StringBuilder(); final NodeList list = elem.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { final Node item = list.item(i); if ((item instanceof CharacterData && !(item instanceof Comment)) || item instanceof EntityReference) { str.append(item.getNodeValue()); } } return str.toString(); } public static List<Node> getChildNodes(final Node node) { final NodeList list = node.getChildNodes(); final List<Node> result = Lists.newArrayList(); for (int i = 0; i < list.getLength(); i++) { final Node child = list.item(i); result.add(child); } return result; } }