Java XML Attribute from Element getIntAttributeValue(Element element, String attribute)

Here you can find the source of getIntAttributeValue(Element element, String attribute)

Description

get Int Attribute Value

License

Open Source License

Declaration

public static int getIntAttributeValue(Element element, String attribute) 

Method Source Code

//package com.java2s;

import org.w3c.dom.*;

public class Main {
    public static int getIntAttributeValue(Element element, String attribute) {
        int ret;//www .j  ava 2  s . c o m

        Attr attr = element.getAttributeNode(attribute);

        try {
            ret = Integer.valueOf(attr.getValue());
        } catch (NumberFormatException e) {
            ret = 0;
        }
        return ret;
    }
}

Related

  1. getIntAttribute(Element elem, String attName, boolean mandatory, int defaultValue)
  2. getIntAttribute(Element element, String attribute)
  3. getIntAttribute(Element element, String name, int defaultValue)
  4. getIntAttribute(NamedNodeMap namedNodeMap, String name)
  5. getIntAttributeIgnoreCase(Element ele, String attr, int defaultvalue)
  6. getInteger(final org.w3c.dom.Element element, final String attr, int def)
  7. getIntegerAttribute(Element el, String attribute)
  8. getIntegerAttribute(Element element, String name)
  9. getStringAttr(Element element, String name, String def)