get Attribute As Hex from Element - Android XML

Android examples for XML:XML Attribute

Description

get Attribute As Hex from Element

Demo Code


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

public class Main {
    public static Integer getAttribAsHex(Element e, String name, Integer dft) {
        String num = getAttribute(e, name);
        return num.equals("") ? dft : Integer.parseInt(num, 16);
    }//www .j av a  2 s .  c  o  m

    public static String getAttribute(Element e, String name) {
        if (e.getAttribute(name) == null)
            return "";
        return e.getAttribute(name);
    }
}

Related Tutorials