Android XML Node Value Get getTextContent(Node n)

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

Description

get Text Content

Declaration

public static String getTextContent(Node n) 

Method Source Code

//package com.java2s;

import org.w3c.dom.*;

public class Main {
    public static String getTextContent(Node n) {
        StringBuffer buffer = new StringBuffer();
        NodeList childList = n.getChildNodes();
        Node child;/*w w  w  . j ava  2  s  .  c om*/
        short nodetype;
        for (int i = 0; i < childList.getLength(); i++) {
            child = childList.item(i);
            nodetype = child.getNodeType();
            if (nodetype != Node.TEXT_NODE
                    && nodetype != Node.CDATA_SECTION_NODE)
                continue;
            buffer.append(child.getNodeValue());
        }
        return buffer.toString();
    }
}

Related

  1. getNodeValue(Node node)
  2. getText(Node n)
  3. getText(Node node, String tag)
  4. getText(Node node, String tag)
  5. getText(Node node, String tag)
  6. getTextContent(Node n)
  7. getTextContent(Node n, StringBuffer buf)
  8. getTextContent(org.w3c.dom.Node element)
  9. getTextNodeValue(Node node)