Here you can find the source of getText(Node node)
Parameter | Description |
---|---|
node | Node. |
public static String getText(Node node)
//package com.java2s; /* Please see the license information at the end of this file. */ import org.w3c.dom.*; public class Main { /** Gets text for a node. *//from ww w. j ava2 s . com * @param node Node. * * @return Value of first child text node, or the empty * string if none found, with leading and trailing * white space trimmed. */ public static String getText(Node node) { NodeList children = node.getChildNodes(); int numChildren = children.getLength(); for (int i = 0; i < numChildren; i++) { Node child = children.item(i); if (child.getNodeType() == Node.TEXT_NODE) return child.getNodeValue().trim(); } return ""; } }