Here you can find the source of getText(Element aElement)
Parameter | Description |
---|---|
aElement | a parameter |
public static String getText(Element aElement)
//package com.java2s; import org.w3c.dom.*; public class Main { /**/* ww w. j a v a 2s . co m*/ * Returns a concatenation of all of the text nodes and CDATA nodes that are * immediate children of this element. * * @param aElement */ public static String getText(Element aElement) { // short return if no element has been passed if (aElement == null) return null; StringBuilder buffer = new StringBuilder(); NodeList nl = aElement.getChildNodes(); for (int i = 0; nl.item(i) != null; i++) { Node child = nl.item(i); switch (child.getNodeType()) { case Node.CDATA_SECTION_NODE: case Node.TEXT_NODE: buffer.append(child.getNodeValue()); } } return buffer.toString(); } }