Java XML Element Get Value getTextContents(Element e)

Here you can find the source of getTextContents(Element e)

Description

get Text Contents

License

Open Source License

Declaration

public static String getTextContents(Element e) 

Method Source Code

//package com.java2s;
// modify it under the terms of the GNU General Public License

import org.w3c.dom.Element;

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

public class Main {
    public static String getTextContents(Element e) {
        if (!e.hasChildNodes())
            return null;

        StringBuffer buf = new StringBuffer();
        NodeList list = e.getChildNodes();
        int len = list.getLength();
        String text;/*from ww w . j  av a 2  s. c o m*/
        for (int i = 0; i < len; i++) {
            text = ((Node) list.item(i)).getNodeValue();
            if (text != null)
                buf.append(text);
        }
        return buf.toString();
    }
}

Related

  1. getTextContent(Element element)
  2. getTextContent(Element element)
  3. getTextContentFromFirstElementByTagName(Element element, String tagName)
  4. getTextContentOfElement(Element elem, String tagName, boolean required)
  5. getTextContentOfElements(Element elem, String tagName)
  6. getTextData(Element element)
  7. getTextElementValue(Element ele)
  8. getTextFromFirstSubEleByName(Element element, String tagName)
  9. getTextFromTag(Element current, String tag)