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 n, String attr)
get Attribute
Node nn = n.getAttributes().getNamedItem(attr);
if (nn == null)
    return null;
return nn.getNodeValue();
StringgetAttribute(Node n, String attr, String def)
get Attribute
NamedNodeMap attrs = n.getAttributes();
if (attrs == null)
    return def;
Node ret = attrs.getNamedItem(attr);
if (ret == null)
    return def;
else
    return ret.getNodeValue();
...
StringgetAttribute(Node n, String name)
get Attribute
if (n == null || name == null)
    return null;
if (n instanceof Element)
    return ((Element) n).getAttribute(name);
return null;
StringgetAttribute(Node node, String att_name)
Return the value of an attribute of a node or an empty string if the attribute is not present.
if (node == null)
    return "";
return getText(node.getAttributes().getNamedItem(att_name));
StringgetAttribute(Node node, String attName, boolean domLevel3)
get Attribute
final Node attNode = node.getAttributes().getNamedItem(attName);
if (attNode == null) {
    return null;
return getTextContent(attNode, domLevel3);
NodegetAttribute(Node node, String attr)
get Attribute
return node.getAttributes().getNamedItem(attr);
StringgetAttribute(Node node, String attr)
Gets a named attribute of a Node

if (node == null)
    throw new IllegalArgumentException("Node argument cannot be null");
if (attr == null)
    throw new IllegalArgumentException("Node attribute argument cannot be null");
NamedNodeMap map = node.getAttributes();
if (map != null) {
    Node an = map.getNamedItem(attr);
    if (an != null)
...
NodegetAttribute(Node node, String attr)
Get the value of a specific attribute on an XML node
return node.getAttributes().getNamedItem(attr);
StringgetAttribute(Node node, String attr)
get Attribute
return getAttribute(node, attr, null);
StringgetAttribute(Node node, String attribName)
get the value for an attribute.
String attributeVal = getAttribute(node, attribName, null);
assert (attributeVal != null) : "no attribute named '" + attribName + "' for node '" + node.getNodeName()
        + "' val=" + node.getNodeValue();
return attributeVal;