Here you can find the source of getElementText(Element n)
public static String getElementText(Element n)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getElementText(Element n) { NodeList childNodes = n.getChildNodes(); String result = new String(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.TEXT_NODE) { result += node.getNodeValue(); }//from w w w . ja v a 2s . c o m } return result; } }