Here you can find the source of extractNodeText(Node node)
public static String extractNodeText(Node node)
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String extractNodeText(Node node) { if (node.getNodeType() == Node.CDATA_SECTION_NODE) return node.getNodeValue(); if (node.getNodeType() == Node.TEXT_NODE) return node.getNodeValue(); NodeList nodelist = node.getChildNodes(); String ctext = ""; for (int i = 0; i < nodelist.getLength(); i++) { Node subnode = nodelist.item(i); ctext += extractNodeText(subnode); }// www. ja v a2 s . co m return ctext; } }