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

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

Description

first Child Of Type

Declaration

public static Element firstChildOfType(Node x, String s) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    public static Element firstChildOfType(Node x, String s) {
        if (x != null) {
            Node n = x.getFirstChild();
            Node last = x.getLastChild();
            while (n != null) {
                if (n.getNodeName().equals(s)) {
                    return (Element) n;
                }/*from  w w  w.  j  a v  a2  s  .com*/
                if (n == last)
                    break; // DSM handle possible bug in getNextSibling()
                n = n.getNextSibling();
            }
        }
        return null;
    }
}

Related

  1. getFirstChild(Node node, String xmlLocalName)
  2. getFirstMatchingChildNode(Node node, String nodeName)
  3. getFirstMatchingChildNode(Node node, String nodeName, String attributeName, List attributeValues)
  4. children(Node x)
  5. childrenOfType(Node x, String s)
  6. getMatchingChildNodes(Node node, String nodeName, String attributeName, List attributeValues)
  7. firstDescendantOfType(Node x, String s)
  8. firstValueOfType(Node x, String s)
  9. getSet(Node rootNode, Set result, Node exclude, boolean com)