Android XML Node Child Get getChild(Node node, String tag)

Here you can find the source of getChild(Node node, String tag)

Description

get Child

Declaration

private static Node getChild(Node node, String tag) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    private static Node getChild(Node node, String tag) {
        if (node == null) {
            return null;
        }/*w  ww.  j av  a 2  s  .com*/

        NodeList childNodes = node.getChildNodes();
        if (childNodes == null) {
            return null;
        }

        for (int i = 0; i < childNodes.getLength(); i++) {
            Node item = childNodes.item(i);
            if (item != null) {
                String name = item.getNodeName();
                if (tag.equalsIgnoreCase(name)) {
                    return item;
                }
            }
        }
        return null;
    }
}

Related

  1. getChild(Node node, String tag)
  2. getChild(Node node, String tag)
  3. getChildElement(Node element, String childNodeName)
  4. getChildElement(Node element, String childNodeName)
  5. getChildElementText(Node element, String childNodeName)