find First XML Child Element from Element - Android XML

Android examples for XML:XML Child Element

Description

find First XML Child Element from Element

Demo Code


//package com.java2s;
import org.w3c.dom.Element;

public class Main {
    public static Element findFirstChildElement(Element parent) {
        org.w3c.dom.Node ret = parent.getFirstChild();
        while (ret != null && (!(ret instanceof Element))) {
            ret = ret.getNextSibling();/*  w w w  .ja va  2  s .  com*/
        }
        return (Element) ret;
    }
}

Related Tutorials