Android XML Element Child Get findChildElementWithAttribute(Element parent, String name, String attribute, String value)

Here you can find the source of findChildElementWithAttribute(Element parent, String name, String attribute, String value)

Description

find Child Element With Attribute

Declaration

public static Element findChildElementWithAttribute(Element parent,
            String name, String attribute, String value) 

Method Source Code

//package com.java2s;
import org.w3c.dom.Element;

public class Main {
    public static Element findChildElementWithAttribute(Element parent,
            String name, String attribute, String value) {
        if (parent == null) {
            return null;
        }// w ww.  ja v  a 2 s .  co m
        org.w3c.dom.Node ret = parent.getFirstChild();
        while (ret != null
                && (!(ret instanceof Element)
                        || !ret.getNodeName().equals(name)
                        || ((Element) ret).getAttribute(attribute) == null || !((Element) ret)
                        .getAttribute(attribute).equals(value))) {
            ret = ret.getNextSibling();
        }
        return (Element) ret;
    }
}

Related

  1. findChild(Element parent, String tagName)
  2. findChildElement(Element parent, String name)
  3. findChildren(Element parent, String tagName)
  4. findFirstChildElement(Element parent)
  5. firstChildWithName(Element element, String name)
  6. getChild(Element element, String name)