Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; public class Main { public static Float getAttribAsFloat(Element e, String name, Float dft) { String num = getAttribute(e, name); return num.equals("") ? dft : Float.parseFloat(num); } public static String getAttribute(Element e, String name) { if (e.getAttribute(name) == null) return ""; return e.getAttribute(name); } }