Java XML Node Text Value getTextContent(Node e)

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

Description

get Text Content

License

Open Source License

Declaration

public static String getTextContent(Node e) 

Method Source Code

//package com.java2s;
/**/*  w ww.  j  a  v a2 s.c om*/
 * This file belongs to the BPELUnit utility and Eclipse plugin set. See enclosed
 * license file for more information.
 */

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

public class Main {
    public static String getTextContent(Node e) {
        StringBuilder sb = new StringBuilder();

        NodeList children = e.getChildNodes();
        if (children != null) {
            for (int i = 0; i < children.getLength(); i++) {
                Node n = children.item(i);
                if (n.getNodeType() == Node.TEXT_NODE) {
                    sb.append(n.getNodeValue());
                }
            }
        }

        return sb.toString();
    }
}

Related

  1. getTextContent(final Node node)
  2. getTextContent(final Node node, final String defaultValue)
  3. getTextContent(final Node node, final StringBuffer sb)
  4. getTextContent(final Node xmlNode)
  5. getTextContent(Node baseNode)
  6. getTextContent(Node element)
  7. getTextContent(Node node)
  8. getTextContent(Node node)
  9. getTextContent(Node node)