Java tutorial
//package com.java2s; import org.w3c.dom.Element; public class Main { public static boolean getOptionalBoolean(Element element, String attribute, boolean defaultValue) { String s = element.getAttribute(attribute); if (s == null || "".equals(s)) { return defaultValue; } else { return Boolean.valueOf(s).booleanValue(); } } }