Here you can find the source of getNodeValue(Element node)
Parameter | Description |
---|---|
node | The node to get the text value for. |
public static String getNodeValue(Element node)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class Main { /**//from w ww . j av a2s. co m * This will get the text value of an element. * * @param node The node to get the text value for. * @return The text of the node. */ public static String getNodeValue(Element node) { StringBuilder sb = new StringBuilder(); NodeList children = node.getChildNodes(); int numNodes = children.getLength(); for (int i = 0; i < numNodes; i++) { Node next = children.item(i); if (next instanceof Text) { sb.append(next.getNodeValue()); } } return sb.toString(); } }