Java XML Attribute from Element getIntegerAttribute(Element el, String attribute)

Here you can find the source of getIntegerAttribute(Element el, String attribute)

Description

get Integer Attribute

License

Apache License

Declaration

public static int getIntegerAttribute(Element el, String attribute) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Element;

public class Main {
    public static int getIntegerAttribute(Element el, String attribute) {
        String attributeValue = el.getAttribute(attribute);
        try {//from   www .  j a v a2 s  .  c  o  m
            return Integer.parseInt(attributeValue);
        } catch (NumberFormatException e) {
            return -1;
        }
    }
}

Related

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