Here you can find the source of getFirstLevelTextContent(Node node)
public static String getFirstLevelTextContent(Node node)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getFirstLevelTextContent(Node node) { NodeList list = node.getChildNodes(); StringBuilder textContent = new StringBuilder(); for (int i = 0; i < list.getLength(); ++i) { Node child = list.item(i); if (child.getNodeType() == Node.TEXT_NODE) textContent.append(child.getTextContent()); }//from w ww .j ava2 s .c om return textContent.toString().trim(); } }