Java tutorial
//package com.java2s; import org.w3c.dom.*; public class Main { /** * Get a boolean attribute from the supplied element. * @param element The element. * @param attribName The attribute name. * @return True if the attribute value is "true" (case insensitive), otherwise false. */ public static boolean getBooleanAttrib(Element element, String attribName) { String attribVal = element.getAttribute(attribName); return (attribVal != null && attribVal.equalsIgnoreCase("true")); } /** * Get a boolean attribute from the supplied element. * @param element The element. * @param namespaceURI Namespace URI of the required attribute. * @param attribName The attribute name. * @return True if the attribute value is "true" (case insensitive), otherwise false. */ public static boolean getBooleanAttrib(Element element, String attribName, String namespaceURI) { String attribVal = element.getAttributeNS(namespaceURI, attribName); return (attribVal != null && attribVal.equalsIgnoreCase("true")); } /** * Get an Attribute from an Element. Returns an empty String if none found * http://www.java2s.com/Code/Java/XML/ReturnalistofnamedElementswithaspecificattributevalue.htm * @param element the containing Element. * @param name the attribute name. * @return Attribute as a String. */ public static String getAttribute(Element element, String name) { return element.getAttribute(name); } }