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 a va2s . c om * 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) { String retval = ""; NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node next = children.item(i); if (next instanceof Text) { retval = next.getNodeValue(); } } return retval; } }