Here you can find the source of getNodeValue(Node node)
Parameter | Description |
---|---|
node | Node |
public static String getNodeValue(Node node)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**// w ww.java 2s. c o m * Gets a node's text value given its parent node and the name of the wanted child node.<br> * * @param fatherNode the parent node * @param nodeName name of the wanted child node * @return String text node value */ public static String getNodeValue(Node fatherNode, String nodeName) { String value = null; if (((Element) fatherNode).getElementsByTagName(nodeName) != null) { Node node = ((Element) fatherNode).getElementsByTagName( nodeName).item(0); value = node.getTextContent(); if (value != null) { value = value.trim(); } } return value; } /** * Gets the node value * * @param node Node * @return String node value */ public static String getNodeValue(Node node) { String value = null; if (node.getFirstChild() != null) { value = node.getFirstChild().getNodeValue(); } return value; } }