Android examples for XML:XML Element
get XML Element As Integer
//package com.java2s; import org.w3c.dom.Element; public class Main { public static Integer getElementAsInteger(Element e, String name, Integer dft) {/*from w w w . j ava 2 s . c o m*/ String num = getElement(e, name); return num.equals("") ? dft : Integer.parseInt(num); } public static String getElement(Element e, String name) { if (e.getElementsByTagName(name) == null) return ""; if (e.getElementsByTagName(name).item(0) == null) return ""; return e.getElementsByTagName(name).item(0).getTextContent(); } }