Here you can find the source of getAttributeValueAsBoolean(Element el, String attrName)
public static boolean getAttributeValueAsBoolean(Element el, String attrName)
//package com.java2s; //License from project: Apache License import javax.xml.namespace.QName; import org.w3c.dom.Element; public class Main { /** Get the boolean value from the given attribute. */ public static boolean getAttributeValueAsBoolean(Element el, String attrName) { return getAttributeValueAsBoolean(el, new QName(attrName)); }// w ww . jav a 2 s . c o m /** Get the boolean value from the given attribute. */ public static boolean getAttributeValueAsBoolean(Element el, QName attrName) { String attrVal = getAttributeValue(el, attrName); boolean ret = "true".equalsIgnoreCase(attrVal) || "1".equalsIgnoreCase(attrVal); return ret; } /** * Get the value from the given attribute * @return null if the attribute value is empty or the attribute is not present */ public static String getAttributeValue(Element el, String attrName) { return getAttributeValue(el, new QName(attrName)); } /** * Get the value from the given attribute * @return null if the attribute value is empty or the attribute is not present */ public static String getAttributeValue(Element el, QName attrName) { String attr = null; if ("".equals(attrName.getNamespaceURI())) attr = el.getAttribute(attrName.getLocalPart()); else attr = el.getAttributeNS(attrName.getNamespaceURI(), attrName.getLocalPart()); if ("".equals(attr)) attr = null; return attr; } }