Java XML Attribute Set attributeIntValue(Element e, String attr)

Here you can find the source of attributeIntValue(Element e, String attr)

Description

attribute Int Value

License

Open Source License

Declaration

public static int attributeIntValue(Element e, String attr) 

Method Source Code

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

import org.w3c.dom.Element;

public class Main {
    public static int attributeIntValue(Element e, String attr) {
        return attributeIntValue(e, attr, null);
    }//  w  w w  .  ja  va2  s .  c  om

    public static int attributeIntValue(Element e, String attr, Integer defaultValue) {
        if (!e.hasAttribute(attr)) {
            return defaultValue;
        }
        if (e.getAttribute(attr).equals("yes") || e.getAttribute(attr).equals("true")) {
            return 1;
        }
        return Integer.parseInt(e.getAttribute(attr));
    }
}

Related

  1. attribute(Node node, String... attributes)
  2. attributeBooleanGet(Element e, String name, boolean defaultValue)
  3. attributeBooleanSet(Element base, String name, boolean value, boolean defaultValue)
  4. attributeBoolValue(Element e, String attr)
  5. attributeFloat(Node node, String attributeName)
  6. attributeMap(Element element)
  7. attributeOrNull(Node node, String... attributes)
  8. attributeOrValue(Element element, String mainAttribute, String... alternateAttributes)
  9. attributes(final Element element)