Android XML Node Child Get childrenOfType(Node x, String s)

Here you can find the source of childrenOfType(Node x, String s)

Description

children Of Type

Declaration

public static ArrayList<Element> childrenOfType(Node x, String s) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    public static ArrayList<Element> childrenOfType(Node x, String s) {
        ArrayList<Element> a = new ArrayList<Element>();
        Node n = x.getFirstChild();
        Node last = x.getLastChild();
        while (n != null) {
            if (n.getNodeName().equals(s)) {
                a.add((Element) n);
            }/*  w  w  w.  j a  v a 2 s  .c  o  m*/
            if (n == last)
                break;
            n = n.getNextSibling();
        }
        return a;
    }
}

Related

  1. getFirstChild(Node node, String namespace, String name)
  2. getFirstChild(Node node, String xmlLocalName)
  3. getFirstMatchingChildNode(Node node, String nodeName)
  4. getFirstMatchingChildNode(Node node, String nodeName, String attributeName, List attributeValues)
  5. children(Node x)
  6. firstChildOfType(Node x, String s)
  7. getMatchingChildNodes(Node node, String nodeName, String attributeName, List attributeValues)
  8. firstDescendantOfType(Node x, String s)
  9. firstValueOfType(Node x, String s)