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

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

Description

first Value Of Type

Declaration

public static String firstValueOfType(Node x, String s) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static String firstValueOfType(Node x, String s) {
        Node n = x.getFirstChild();
        Node last = x.getLastChild();
        while (n != null) {
            if (n.getNodeName().equals(s)) {
                NodeList nodes = n.getChildNodes();
                String result = "";
                for (int i = 0; i < nodes.getLength(); i++) {
                    Node m = nodes.item(i);
                    result += m.getNodeValue();
                }/*  ww w .  java 2 s.co  m*/
                return result;
            }
            if (n == last)
                break;
            n = n.getNextSibling();
        }
        return null;

    }
}

Related

  1. children(Node x)
  2. childrenOfType(Node x, String s)
  3. firstChildOfType(Node x, String s)
  4. getMatchingChildNodes(Node node, String nodeName, String attributeName, List attributeValues)
  5. firstDescendantOfType(Node x, String s)
  6. getSet(Node rootNode, Set result, Node exclude, boolean com)
  7. getSetRec(final Node rootNode, final Set result, final Node exclude, final boolean com)