Android XML Node Attribute Get getElementIntAttr(Node element, String attrName)

Here you can find the source of getElementIntAttr(Node element, String attrName)

Description

get Element Int Attr

Declaration

public static int getElementIntAttr(Node element, String attrName) 

Method Source Code

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

public class Main {
    public static int getElementIntAttr(Node element, String attrName) {
        String attrValue = getElementAttr(element, attrName);

        if (attrValue != null) {
            return Integer.parseInt(attrValue);
        }/*from w  ww  .j a  va 2 s .  co m*/

        return 0;
    }

    public static String getElementAttr(Node element, String attrName) {
        for (int i = 0; i < element.getAttributes().getLength(); i++) {
            Node child = element.getAttributes().item(i);
            if (child.getNodeName().equals(attrName)) {
                return child.getNodeValue();
            }
        }

        return null;
    }
}

Related

  1. getAttributeValue(Node node, String attributeName)
  2. getAttributeValueAsInt(Node node, String attributeName)
  3. getElementAttr(Node element, String attrName)
  4. getElementAttr(Node element, String attrName)
  5. getElementIntAttr(Node element, String attrName)
  6. getEnumAttribute(Node archiveNode, String attrName, Object[] values, Object defaultValue)
  7. getNodeAttribute(Node node, String name)
  8. getNodeAttribute(Node node, String name, String def)
  9. nodeMatchesAttributeFilter(Node node, String attributeName, List attributeValues)