Java XML Attribute Read readIntAttr(Element element, String attributeName, int defaultValue)

Here you can find the source of readIntAttr(Element element, String attributeName, int defaultValue)

Description

read Int Attr

License

Open Source License

Declaration

public static int readIntAttr(Element element, String attributeName, int defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;

public class Main {
    public static int readIntAttr(Element element, String attributeName, int defaultValue) {
        String attributeValue = element.getAttribute(attributeName);
        try {/*from  w w  w  .j av a2 s  .c  om*/
            return Integer.parseInt(attributeValue);
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
}

Related

  1. readBooleanAttribute(Element elem, String name, boolean defaultValue)
  2. readBooleanAttributeElement(final XMLStreamReader reader, final String attributeName)
  3. readFloat(Node node, String attributeName, float def)
  4. readFloatAttribute(XMLStreamReader reader, String attributeName)
  5. readInt(Node node, String attributeName, int def)
  6. readIntegerAttribute(Element elem, String name, int defaultValue)
  7. readNodeAttributes(Element elem, Object[] map)