Here you can find the source of getFirstTextChild(Node node)
public static String getFirstTextChild(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 getFirstTextChild(Node node) { NodeList nodeList = node.getChildNodes(); if (nodeList != null) { for (int index = 0; index < nodeList.getLength(); index++) { Node child = nodeList.item(index); if (child.getNodeType() == Node.TEXT_NODE) { if (child.getNodeValue() != null && child.getNodeValue().trim().length() > 0) { return child.getNodeValue(); }/*from ww w . j a v a2 s . com*/ } } } return null; } }