Here you can find the source of getTagText(Element ele)
public static String getTagText(Element ele)
//package com.java2s; import org.w3c.dom.*; public class Main { /**//from w w w . j a v a 2 s .com * Scans the tag's children and returns the first text element found */ public static String getTagText(Element ele) { NodeList nl = ele.getChildNodes(); int size = nl.getLength(); Node node = null; int i = 0; for (; i < size; i++) { node = nl.item(i); if (node instanceof Text) break; } if (i == size || node == null) return null; return ((Text) node).getData(); } }