Java XML Element Get Value getText(Element config)

Here you can find the source of getText(Element config)

Description

returns the concatenation of all text children within the node.

License

Open Source License

Declaration

public static String getText(Element config) 

Method Source Code

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

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

public class Main {
    /**// w w  w. j  av a2  s .  co m
     * returns the concatenation of all text children within the node. Does not
     * recurse into subelements.
     */
    public static String getText(Element config) {
        if (config == null)
            return new String("");
        NodeList children = config.getChildNodes();
        Node node;
        String out = "";
        for (int i = 0; i < children.getLength(); i++) {
            node = children.item(i);
            if (node instanceof Text) {
                out += node.getNodeValue();
            }
        }
        return out;
    }
}

Related

  1. getTagValue(Element e, String tag)
  2. getTagValue(Element element, String tagName)
  3. getTagValue(Element element, String tagName)
  4. getText(Element aElement)
  5. getText(Element config)
  6. getText(Element e)
  7. getText(Element el)
  8. getText(Element elem)
  9. getText(Element elem)