get Child XML Element from Node - Android XML

Android examples for XML:XML Node

Description

get Child XML Element from Node

Demo Code


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

public class Main {
    public static Node getChildElement(Node element, String childNodeName) {
        for (int i = 0; i < element.getChildNodes().getLength(); i++) {
            Node child = element.getChildNodes().item(i);
            if (child.getNodeName().equals(childNodeName)) {
                return child;
            }//from   ww  w  . j  a v a2 s  .com
        }

        return null;
    }
}

Related Tutorials