Here you can find the source of getTextValue(Element valueEle)
public static String getTextValue(Element valueEle)
//package com.java2s; //License from project: Open Source License 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; public class Main { /**/*from w w w . j av a 2 s.c om*/ * Extract the text symbol from the given DOM element, ignoring XML comments. * <p>Appends all CharacterData nodes and EntityReference nodes * into a single String symbol, excluding Comment nodes. * @see CharacterData * @see EntityReference * @see Comment */ public static String getTextValue(Element valueEle) { StringBuffer value = new StringBuffer(); NodeList nl = valueEle.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node item = nl.item(i); if (item instanceof CharacterData && !(item instanceof Comment) || item instanceof EntityReference) value.append(item.getNodeValue()); } return value.toString(); } }