Here you can find the source of getTextTrim(Element elto)
public static String getTextTrim(Element elto)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class Main { public static String getTextTrim(Element elto) { StringBuffer content = new StringBuffer(); NodeList contentE = elto.getChildNodes(); int i = 0; while (contentE.item(i) != null && (contentE.item(i).getNodeType() == Node.TEXT_NODE || contentE .item(i).getNodeType() == Node.CDATA_SECTION_NODE)) { content.append(((Text) contentE.item(i)).getNodeValue()); i++;/*from www. j a v a 2s . c om*/ } return content.toString().trim(); } }