Android XML Node Child Get getChildrenOfName(Node node, String name)

Here you can find the source of getChildrenOfName(Node node, String name)

Description

get Children Of Name

Declaration

public static List<Node> getChildrenOfName(Node node, String name) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import java.util.List;

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

public class Main {
    public static List<Node> getChildrenOfName(Node node, String name) {
        List<Node> res = new ArrayList<Node>();
        NodeList childNodes = node.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node item = childNodes.item(i);

            String localName = item.getNodeName();
            if (name.equals(localName)) {
                res.add(item);//from w w  w  .  ja va 2s  .c  o  m
            }
        }
        return res;
    }
}

Related

  1. getChildTagValue(Node node, String tag)
  2. getChildText(Node n)
  3. getChildren(Node node, String name)
  4. getChildren(Node node, String name)
  5. getChildren(Node node, String name)
  6. getFirstChild(Node node, String namespace, String name)
  7. getFirstChild(Node node, String xmlLocalName)
  8. getFirstMatchingChildNode(Node node, String nodeName)
  9. getFirstMatchingChildNode(Node node, String nodeName, String attributeName, List attributeValues)