Android XML Node Attribute Get nodeMatchesAttributeFilter(Node node, String attributeName, List attributeValues)

Here you can find the source of nodeMatchesAttributeFilter(Node node, String attributeName, List attributeValues)

Description

node Matches Attribute Filter

Declaration

static boolean nodeMatchesAttributeFilter(Node node,
            String attributeName, List<String> attributeValues) 

Method Source Code

//package com.java2s;

import java.util.List;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    static boolean nodeMatchesAttributeFilter(Node node,
            String attributeName, List<String> attributeValues) {
        if (attributeName == null || attributeValues == null) {
            return true;
        }/*from   www.  ja  va  2  s  . com*/
        NamedNodeMap attrMap = node.getAttributes();
        if (attrMap != null) {
            Node attrNode = attrMap.getNamedItem(attributeName);
            if (attrNode != null
                    && attributeValues.contains(attrNode.getNodeValue())) {
                return true;
            }
        }
        return false;
    }

    static String getNodeValue(Node node) {
        return (node == null || node.getFirstChild() == null || node
                .getFirstChild().getNodeValue() == null) ? null : node
                .getFirstChild().getNodeValue().trim();
    }
}

Related

  1. getElementIntAttr(Node element, String attrName)
  2. getElementIntAttr(Node element, String attrName)
  3. getEnumAttribute(Node archiveNode, String attrName, Object[] values, Object defaultValue)
  4. getNodeAttribute(Node node, String name)
  5. getNodeAttribute(Node node, String name, String def)
  6. findNextElementWithAttribute(Node ret, String name, String attribute, String value)