Java XML Node Text Value extractNodeText(Node node)

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

Description

extract Node Text

License

Open Source License

Declaration

public static String extractNodeText(Node node) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static String extractNodeText(Node node) {
        if (node.getNodeType() == Node.CDATA_SECTION_NODE)
            return node.getNodeValue();
        if (node.getNodeType() == Node.TEXT_NODE)
            return node.getNodeValue();
        NodeList nodelist = node.getChildNodes();
        String ctext = "";
        for (int i = 0; i < nodelist.getLength(); i++) {
            Node subnode = nodelist.item(i);
            ctext += extractNodeText(subnode);
        }//  www.  ja  v a2  s  . co  m
        return ctext;
    }
}

Related

  1. addElementText(Node test, List holder)
  2. createNewTextElement(Node elem, String tag, String value)
  3. existNode(Node node, String nodeName, String textValue)
  4. extractText(Node node)
  5. findNodeText(Node node)
  6. get_inner_text(Node node)
  7. getAppInfoText(final Node node)