find Child XML Node by node name - Android XML

Android examples for XML:XML Child Element

Description

find Child XML Node by node name

Demo Code

// Copyright (c) 2004-2008 IBM Corporation and others. All Rights Reserved.
//package com.java2s;
import org.w3c.dom.*;

public class Main {
    public static Node findChild(Node node, String chName) {
        for (Node child = node.getFirstChild(); child != null; child = child
                .getNextSibling()) {/*  www  . j  a  va  2s.co  m*/
            if (child.getNodeType() == Node.ELEMENT_NODE
                    && child.getNodeName().equals(chName)) {
                return child;
            }
        }
        return null;
    }
}

Related Tutorials