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

StringgetAttributeValue(Node node, String attributeName)
Get the attribute value of the node.
Node attribute = node.getAttributes().getNamedItem(attributeName);
if (attribute != null) {
    return attribute.getNodeValue();
} else {
    return null;
intgetAttributeValue(Node node, String attributeName, int defaultValue)
get the attribute with the given name from the given node as an int value
NamedNodeMap nnm = node.getAttributes();
Node attribute = nnm.getNamedItem(attributeName);
if (attribute == null) {
    return defaultValue;
} else
    try {
        return Integer.parseInt(attribute.getNodeValue());
    } catch (NumberFormatException e) {
...
StringgetAttributeValue(Node node, String attrName)
Returns string value of the named attribute of the node.
Node attr = node.getAttributes().getNamedItem(attrName);
return attr == null ? null : attr.getNodeValue();
StringgetAttributeValue(Node node, String attrName)
Gets the value of a specific attribute attached to the given node
if (node == null)
    return null;
;
NamedNodeMap map = node.getAttributes();
if (map != null && map.getNamedItem(attrName) != null)
    return map.getNamedItem(attrName).getTextContent();
else
    return null;
...
StringgetAttributeValue(Node node, String name)
get Attribute Value
Node attribute = getAttribute(node, name);
if (attribute != null) {
    return attribute.getNodeValue();
return null;
StringgetAttributeValue(Node node, String name)
get Attribute Value
Node attr = getAttribute(node, name);
return (attr != null) ? attr.getNodeValue() : null;
StringgetAttributeValue(Node node, String name)
Get the value of a node's attribute.
if (node instanceof Document)
    node = ((Document) node).getDocumentElement();
if (!(node instanceof Element))
    return "";
return ((Element) node).getAttribute(name);
booleangetAttributeValue(Node node, String name, boolean defaultValue)
get Attribute Value
String str = getAttributeValue(node, name);
if (str == null) {
    return defaultValue;
} else {
    return "true".equals(str);
StringgetAttributeValue(Node node, String name, String defaultValue)
get Attribute Value
try {
    return node.getAttributes().getNamedItem(name).getNodeValue();
} catch (Exception ex) {
    return defaultValue;
StringgetAttributeValue(Node sNode, String attribName)
Utility method to fetch the attribute value from the given element node
String value = null;
NamedNodeMap attrs = sNode.getAttributes();
if (attrs != null) {
    Node attr = attrs.getNamedItem(attribName);
    if (attr != null) {
        value = attr.getNodeValue();
return value;