Android examples for XML:XML Attribute
get Attribute As Integer from XML String
//package com.java2s; import org.w3c.dom.Element; public class Main { public static Integer getAttribAsInteger(Element e, String name, Integer dft) {//w w w . ja v a2s. com String num = getAttribute(e, name); return num.equals("") ? dft : Integer.parseInt(num); } public static String getAttribute(Element e, String name) { if (e.getAttribute(name) == null) return ""; return e.getAttribute(name); } }