Java XML Attribute Get getAttribIntHex(Element ele, String name)

Here you can find the source of getAttribIntHex(Element ele, String name)

Description

Parses the given attribute of this tag as a hexadecimal encoded string and returns it as an int

License

Open Source License

Declaration

public static int getAttribIntHex(Element ele, String name) 

Method Source Code


//package com.java2s;
import org.w3c.dom.*;

public class Main {
    /**/*from w  w  w  . j  ava  2s.  co m*/
     * Parses the given attribute of this tag as a hexadecimal encoded string and
     * returns it as an int
     */
    public static int getAttribIntHex(Element ele, String name) {
        String sval = ele.getAttribute(name);
        int val = 0;
        try {
            val = Integer.parseInt(sval, 16);
        } catch (Exception e) {
        }

        return val;
    }

    public static int parseInt(String val) {
        if (val == null)
            return 0;

        int retVal = 0;
        try {
            retVal = Integer.parseInt(val);
        } catch (Exception e) {
        }
        return retVal;
    }
}

Related

  1. getAttribAsBoolean(Element e, String name, Boolean dft)
  2. getAttribAsFloat(Element e, String name, Float dft)
  3. getAttribBoolean(Element ele, String name)
  4. getAttribByName(Element node, String name)
  5. getAttribFloat(Element ele, String name)
  6. getAttribString(Element ele, String name)
  7. getAttribURL(Element ele, String name, URL docRoot)
  8. getAttribute(Element aElement, String aAttr, String aDefault)
  9. getAttribute(Element e, String attName)