get Int from XML Element attribute - Java XML

Java examples for XML:XML Attribute

Description

get Int from XML Element attribute

Demo Code


//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    public static int getInt(Element element, String attributeName)
            throws NumberFormatException {
        try {//from   ww  w . j  a  va  2s.com
            return Integer.parseInt(element.getAttribute(attributeName));
        } catch (NumberFormatException ex) {
            throw ex;
        }
    }
}

Related Tutorials