Android XML Element Value Get getContent(Element xmlElement)

Here you can find the source of getContent(Element xmlElement)

Description

Get the content value for the given XML element

Declaration

public static String getContent(Element xmlElement) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**/*from   w  w w  .j  av  a2s  .c om*/
     * Get the content value for the given XML element
     */
    public static String getContent(Element xmlElement) {
        if (xmlElement == null) {
            throw new IllegalArgumentException("xmlElement cannot be null");
        }
        StringBuilder content = new StringBuilder();
        for (Node childNode = xmlElement.getFirstChild(); childNode != null; childNode = childNode
                .getNextSibling()) {
            if (childNode.getNodeType() == Node.TEXT_NODE) {
                content.append(childNode.getNodeValue());
            }
        }
        return content.toString();
    }
}

Related

  1. getValue(Element element)
  2. getValue(Element element, String elementName)
  3. getValue(Element item, String str)
  4. getStringValue(String tag, Element element)
  5. getCData(Element element)
  6. getElementText(Element element)
  7. getIntegerValue(String tag, Element element)