Here you can find the source of getValue(Node node)
Parameter | Description |
---|---|
node | a parameter |
public static String getValue(Node node)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**/* ww w .j a v a2s. c o m*/ * * @param node * @return the value of any XML node, or the empty string "" if the node is null */ public static String getValue(Node node) { String val = ""; if (node != null) { if (node instanceof Element) { val = node.getTextContent(); } else if (node instanceof Attr) { val = ((Attr) node).getValue(); } else { val = node.getNodeValue(); } } return val; } }