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

StringgetAttribute(String aAttrName, Node aNode)
get Attribute
return aNode.getAttributes().getNamedItem(aAttrName).getNodeValue();
StringgetAttribute(String attribute, Node node)
get Attribute
if (node != null) {
    Node attr = node.getAttributes().getNamedItem(attribute);
    if (attr != null) {
        return attr.getNodeValue().trim();
return null;
StringgetAttribute(String attribute, Node node)
get Attribute
Node attributeNode = node.getAttributes().getNamedItem(attribute);
if (attributeNode != null)
    return attributeNode.getNodeValue().trim();
return null;
StringgetAttribute(String attribute, Node node)
Convenience for accessing an attribute value (the Node interface is rather ugly)
NamedNodeMap att = node.getAttributes();
Node w = att.getNamedItem(attribute);
if (w == null)
    return null;
return w.getTextContent();
StringgetAttribute(String key, NamedNodeMap map)
Gets the attribute as a string.
Node attr = map.getNamedItem(key);
return attr != null ? attr.getTextContent() : "";
StringgetAttribute(String name, Element el)
Gets the value of the given DOM element's attribute with the specified name.
if (name == null || el == null)
    return null;
if (!el.hasAttribute(name))
    return null;
return el.getAttribute(name);
StringgetAttribute(String name, Element element)
get Attribute
return (element.hasAttribute(name) ? element.getAttribute(name) : null);
StringgetAttribute(String name, Element firstElement, Element secondElement)
Try to get an attribute value from two elements.
String val = firstElement.getAttribute(name);
if (val.length() == 0 && secondElement != null) {
    val = secondElement.getAttribute(name);
return val;
StringgetAttribute(String name, Node node)
get Attribute
if ((node != null) && (node.getAttributes() != null)) {
    Node namedItem = node.getAttributes().getNamedItem(name);
    if (namedItem != null) {
        return namedItem.getNodeValue();
return null;
booleangetAttributeAsBoolean(Element elem, String attribName)
Returns attribute as boolean for class
String atribVal = elem.getAttribute(attribName);
boolean retVal = false;
try {
    retVal = Boolean.valueOf(atribVal).booleanValue();
} catch (Exception e) {
return retVal;