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(Node node, String attrName)
Returns the value of the given attribute.
if (node == null) {
    return null;
Node attr = node.getAttributes().getNamedItem(attrName);
if (attr != null) {
    return attr.getNodeValue();
return null;
...
StringgetAttribute(Node node, String localName, String namespaceURI)
get Attribute
Node attributeNode = node.getAttributes().getNamedItemNS(namespaceURI, localName);
if (attributeNode == null) {
    return null;
return attributeNode.getTextContent();
StringgetAttribute(Node node, String localName, String namespaceURI)
get Attribute
Node attributeNode = node.getAttributes().getNamedItemNS(namespaceURI, localName);
if (attributeNode == null) {
    return null;
return attributeNode.getTextContent();
NodegetAttribute(Node node, String name)
Gets the attribute of the node.
if (node != null && node.hasAttributes()) {
    NamedNodeMap attrs = node.getAttributes();
    return attrs.getNamedItem(name);
return null;
NodegetAttribute(Node node, String name)
get Attribute
NamedNodeMap attributes = node.getAttributes();
return attributes.getNamedItem(name);
StringgetAttribute(Node node, String name)
get Attribute
NamedNodeMap namedNodeMap = node.getAttributes();
if (namedNodeMap == null) {
    return null;
Node attrNode = namedNodeMap.getNamedItem(name);
if (attrNode == null) {
    return null;
return attrNode.getNodeValue();
StringgetAttribute(Node node, String name)
get Attribute
NamedNodeMap attributes = node.getAttributes();
Node attrNode = attributes.getNamedItem(name);
if (attrNode != null)
    return attrNode.getNodeValue();
return null;
StringgetAttribute(Node node, String name)
This method will get the value of an attribute for a given node
NamedNodeMap attrs = node.getAttributes();
if (attrs == null)
    return null;
Attr attr = (Attr) attrs.getNamedItem(name);
if (attr == null)
    return null;
else
    return attr.getNodeValue();
...
StringgetAttribute(Node node, String name)
Gets a named attribute value from a node
NamedNodeMap nm = node.getAttributes();
if (nm == null)
    return null;
Node nn = nm.getNamedItem(name);
if (nn == null)
    return null;
return nn.getNodeValue();
StringgetAttribute(Node node, String name)
get Attribute
Node attr = node.getAttributes().getNamedItem(name);
if (attr == null)
    return null;
else
    return attr.getNodeValue();