Java Utililty Methods XML Attribute Get

List of utility methods to do XML Attribute Get

Description

The list of methods to do XML Attribute Get are organized into topic(s).

Method

booleangetBooleanAttribute(Element el, String name)
get Boolean Attribute
String s = el.getAttribute(name);
if (s == null || "0".equals(s)) {
    return false;
if ("1".equals(s)) {
    return true;
return new Boolean(s).booleanValue();
...
booleangetBooleanAttribute(Element elem, String attName, boolean mandatory)
getBooleanAttribute purpose.
String value = getAttribute(elem, attName, mandatory);
return Boolean.valueOf(value).booleanValue();
booleangetBooleanAttribute(Element elem, String attName, boolean mandatory, boolean defaultValue)
getBooleanAttribute purpose.
String value = getAttribute(elem, attName, mandatory);
if ((value == null) || (value == "")) {
    return defaultValue;
return Boolean.valueOf(value).booleanValue();
booleangetBooleanAttribute(Element element, String attributeName)
Determines whether a specific boolean flag is set on an element.
String value = element.getAttribute(attributeName);
if (value == null) {
    return false;
} else if (value.equals("true")) {
    return true;
} else {
    return false;
booleangetBooleanAttribute(Element element, String key, boolean defValue)
get Boolean Attribute
String v = element.getAttribute(key);
return v.length() == 0 ? defValue : Boolean.parseBoolean(v);
booleangetBooleanAttribute(Element element, String name)
get Boolean Attribute
return Boolean.parseBoolean(getAttribute(element, name));
booleangetBooleanAttribute(Element element, String name, boolean defaultValue)
Get the value of an attribute of the given element with the given name as a boolean, or return the given default value if the attribute is missing or not parseable as a boolean.
String s = element.getAttribute(name);
if (s != null)
    return Boolean.parseBoolean(s);
return defaultValue;
BooleangetBooleanAttribute(Node n, String attributeName)
get Boolean Attribute
Node attrib = n.getAttributes().getNamedItem(attributeName);
if (attrib == null)
    return null;
String value = attrib.getNodeValue();
assert (value != null);
return new Boolean(value);
booleangetBooleanAttribute(Node targetElem, String keyName, boolean defaultValue)
get Boolean Attribute
String enabledStr = getAttribute(targetElem, keyName, null);
if (enabledStr == null) {
    return defaultValue;
return Boolean.parseBoolean(enabledStr);
booleangetBooleanAttributeByName(Node content, String attributeName, boolean defaultTrue)
get Boolean Attribute By Name
String value = getAttributeByName(content, attributeName);
if (defaultTrue) {
    return (value == null) || (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"));
} else {
    return (value != null) && (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"));