Java XML Element Get by Attribute getElementIntAttribute(Element e, String whichAttribute)

Here you can find the source of getElementIntAttribute(Element e, String whichAttribute)

Description

get Element Int Attribute

License

Open Source License

Declaration

static int getElementIntAttribute(Element e, String whichAttribute) 

Method Source Code


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

import org.w3c.dom.Element;

public class Main {
    static int getElementIntAttribute(Element e, String whichAttribute) {
        int val = -1;
        String number = e.getAttribute(whichAttribute);
        if (number != null) {
            try {
                val = Integer.parseInt(number.trim());
            } catch (NumberFormatException ex) {
                val = -1;
            }/*from w w w .j  a  v  a 2 s . c  o  m*/
        }
        return val;
    }
}

Related

  1. findNodeByAttributeValue(NodeList nodeList, String attributeName, String attributeValue)
  2. getElementByAttribute(Element root, String tagname, String attribute, String att_value)
  3. getElementByAttribute(String attr, String value, Element root)
  4. getElementByAttributeValue(List elements, String attName, String attValue)
  5. getElementByAttributeValue(Node start, String tagName, String attrName, String attrValue)
  6. getElementsWithAttribute(Element element, String attribute)
  7. getElementsWithAttribute(Element element, String namespaceURI, String localName, String value, Collection elements)
  8. getElementsWithAttributeEquals( Element root, String attribute, String value)
  9. getElementsWithAttributeEquals(Element root, String attribute, String value, List list)