get XML CDATA from Element - Android XML

Android examples for XML:CDATA

Description

get XML CDATA from Element

Demo Code


//package com.java2s;

import org.w3c.dom.Element;

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

public class Main {
    public static String getCDATA(Element element) {
        NodeList nodeList = element.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node.getNodeType() == Node.CDATA_SECTION_NODE) {
                return node.getNodeValue();
            }// w  ww  .j av a 2 s  .co m
        }
        return null;
    }
}

Related Tutorials