Java XML Node Value getValue(Node node)

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

Description

get Value

License

Open Source License

Declaration

public static String getValue(Node node) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;

public class Main {

    public static String getValue(Node node) {

        StringBuffer value = new StringBuffer();

        if (node != null) {

            int childCount = node.getChildNodes().getLength();

            for (int i = 0; i < childCount; i++) {
                Node childNode = node.getChildNodes().item(i);

                switch (childNode.getNodeType()) {

                case Node.TEXT_NODE:
                case Node.CDATA_SECTION_NODE:

                    value.append(childNode.getNodeValue());
                }//from   w  ww.j  a va 2s .c  o m
            }
        }

        return value.toString();
    }
}

Related

  1. getNodeValue(org.w3c.dom.Node node)
  2. getNodeValue(org.w3c.dom.Node node)
  3. getNodeValueAsDate(Node node)
  4. getNodeValueAsLong(Node node)
  5. getNodeValueAsTime(Node node)
  6. getValue(Node node)
  7. getValue(Node node)
  8. getValue(Node node)
  9. getValue(Node node, short nodeType)