Java XML Node Text Value extractText(Node node)

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

Description

extract Text

License

Open Source License

Declaration

public static String extractText(Node node) 

Method Source Code

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

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

public class Main {
    public static String extractText(Node node) {
        NodeList childNodes = node.getChildNodes();

        if (childNodes.getLength() == 1) {
            Node child = childNodes.item(0);
            if (child.getChildNodes().getLength() == 0
                    && "#text".equals(child.getNodeName())) {
                return child.getNodeValue();
            }//from  w  w  w .ja v a 2s.  com
        }

        return null;
    }
}

Related

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