Java XML Element Get Value getTextValue(Element valueEle)

Here you can find the source of getTextValue(Element valueEle)

Description

get Text Value

License

Open Source License

Declaration

public static String getTextValue(Element valueEle) 

Method Source Code

//package com.java2s;

import org.w3c.dom.CharacterData;
import org.w3c.dom.Comment;

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

public class Main {

    public static String getTextValue(Element valueEle) {

        StringBuffer value = new StringBuffer();
        NodeList nl = valueEle.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node item = nl.item(i);
            if ((item instanceof CharacterData && !(item instanceof Comment)) || item instanceof EntityReference) {
                value.append(item.getNodeValue());
            }//from   ww  w . j ava  2s. com
        }
        return value.toString().trim();
    }
}

Related

  1. getTextValue(Element element, String name)
  2. getTextValue(Element element, String tagName)
  3. getTextValue(Element element, String tagName)
  4. getTextValue(Element node)
  5. getTextValue(Element valueEle)
  6. getTextValue(Element valueEle)
  7. getTextValue(final Element elem)
  8. getTextValue(final Element element, final String tagName)
  9. getTextWithoutTrim(Element elem)