Here you can find the source of getChildText(Node n)
public static String getChildText(Node n)
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getChildText(Node n) { StringBuffer str = new StringBuffer(); NodeList nl = n.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node c = nl.item(i);// ww w. java 2 s .co m if (c.getNodeType() == Node.TEXT_NODE) { str.append(c.getNodeValue()); } } return str.toString(); } }