get Element from XML Element - Android XML

Android examples for XML:XML Element

Description

get Element from XML 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 Element getElement(Element element) {
        NodeList nodeList = element.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                return (Element) node;
            }/*from   w  w  w .  ja v  a  2s. c  o m*/
        }
        return null;
    }
}

Related Tutorials