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

StringgetAtrributeValue(Node node, String attribute)
get Atrribute Value
Node _node = node.getAttributes().getNamedItem(attribute);
return getNodeValue(_node);
StringgetAttr(Element e, String name)
get Attr
String value = e.getAttribute(name);
return ((value == null || value.trim().length() <= 0) ? null : value.trim());
AttrgetAttr(Element elem, String name)
get Attr
return elem.getAttributeNode(name);
StringgetAttr(final Node n, final String attr)
get Attr
final Node attrNode = n.getAttributes().getNamedItem(attr);
if (attrNode != null) {
    return attrNode.getNodeValue();
return null;
StringgetAttr(final Node n, final String attrName)
Gives the value of a given attribute
String value = null;
if (n.hasAttributes()) {
    final NamedNodeMap map = n.getAttributes();
    for (int i = 0; i < map.getLength(); i++) {
        final Node attrNode = map.item(i);
        if (attrNode.getNodeName().equals(attrName)) {
            value = attrNode.getNodeValue();
return value;
StringgetAttr(NamedNodeMap attrs, String name)
get Attr
return getAttr(attrs, name, null);
StringgetAttr(NamedNodeMap attrs, String name, String missing_err)
get Attr
Node attr = attrs == null ? null : attrs.getNamedItem(name);
if (attr == null) {
    if (missing_err == null)
        return null;
    throw new RuntimeException(missing_err + ": missing mandatory attribute '" + name + "'");
String val = attr.getNodeValue();
return val;
...
StringgetAttr(Node n, String name)
get Attr
if (n == null)
    return null;
Node nn = n.getAttributes().getNamedItem(name);
if (nn != null)
    return nn.getNodeValue();
return null;
StringgetAttr(Node node, String attr)
get Attr
final NamedNodeMap attributes = node.getAttributes();
final Node nodeAttr = attributes.getNamedItem(attr);
if (nodeAttr != null) {
    return nodeAttr.getTextContent();
return null;
StringgetAttr(Node node, String name)
get Attr
assert node != null;
try {
    NamedNodeMap attributes = node.getAttributes();
    if (attributes == null)
        throw new Exception("");
    Node attr = attributes.getNamedItem(name);
    if (attr == null)
        throw new Exception("");
...