Java XML Node Text Value getStringValue(Node node)

Here you can find the source of getStringValue(Node node)

Description

Return the String value of a Node.

License

Open Source License

Parameter

Parameter Description
node a parameter

Declaration

public static String getStringValue(Node node) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {
    /**/*from   w ww .j av a2  s.c om*/
     * Return the String value of a Node.
     * @param node
     * @return
     */
    public static String getStringValue(Node node) {
        String value = node.getNodeValue();

        if (node.hasChildNodes()) {
            Node first = node.getFirstChild();

            if (first.getNodeType() == Node.TEXT_NODE) {
                return first.getNodeValue();
            }
        }

        return value;
    }
}

Related

  1. getStrElementValue(Node node)
  2. getString(final Node node, final String default_value)
  3. getString(Node node)
  4. getStringValue(NamedNodeMap values, String name)
  5. getStringValue(Node node)
  6. getTagValue(Node node, String name)
  7. getTagValueWithoutNamespace(Node n)
  8. getText(final Node node)
  9. getText(final Node xmlNode)