get XML Child Node By Name - Android XML

Android examples for XML:XML Child Element

Description

get XML Child Node By Name

Demo Code


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

public class Main {
    public static Node getChildNodeByName(Node node, String childName) {
        NodeList children = node.getChildNodes();
        for (int j = 0; j < children.getLength(); j++) {
            Node child = children.item(j);
            if (child.getNodeName().equals(childName)) {
                return child;
            }/*  w  ww .  j a va2 s.  co  m*/
        }
        return null;
    }
}

Related Tutorials