Here you can find the source of extractText(Node node)
public static String extractText(Node node)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String extractText(Node node) { NodeList childNodes = node.getChildNodes(); if (childNodes.getLength() == 1) { Node child = childNodes.item(0); if (child.getChildNodes().getLength() == 0 && "#text".equals(child.getNodeName())) { return child.getNodeValue(); }//from w w w .ja v a 2s. com } return null; } }