Java XML Node Text Value getTextContent(Node node)

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

Description

get Text Content

License

Open Source License

Declaration

static String getTextContent(Node node) 

Method Source Code

//package com.java2s;
/*  it under the terms of the GNU General Public License as published by    */

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

public class Main {
    static String getTextContent(Node node) {
        NodeList list = node.getChildNodes();

        String text = "";
        int count = 0;

        for (int i = 0; list != null && i < list.getLength(); i++) {
            String value = list.item(i).getNodeValue();

            if (value != null) {
                text += value;/* ww  w.j  a v  a 2  s.  c  o  m*/
                count++;
            }
        }

        if (count == 0) {
            return null;
        }

        return text;
    }
}

Related

  1. getTextContent(Node node)
  2. getTextContent(Node node)
  3. getTextContent(Node node)
  4. getTextContent(Node node)
  5. getTextContent(Node node)
  6. getTextContent(Node node)
  7. getTextContent(Node node)
  8. getTextContent(Node node)
  9. getTextContent(Node node)