Java XML Element Text getSimpleElementText(Element node)

Here you can find the source of getSimpleElementText(Element node)

Description

get Simple Element Text

License

Open Source License

Declaration

public static String getSimpleElementText(Element node) 

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 {
    public static String getSimpleElementText(Element node) {
        if (node == null)
            return null;
        StringBuffer sb = new StringBuffer();
        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            if (child instanceof Text) {
                sb.append(child.getNodeValue());
            }//from  w ww .ja  v  a 2 s  . c o  m
        }
        return sb.toString();
    }
}

Related

  1. getElementTextDataNoEx(Element element, boolean unindent)
  2. getElementTextOrNull(final XMLStreamReader reader)
  3. getElementTextValue(Element element)
  4. getElementTextValue(Element in)
  5. getSimpleElementText(Element element)
  6. getSimpleElementText(Element node)
  7. getSimpleElementText(Element node, boolean trim)
  8. getSimpleElementText(final Element element, final String nodeName)