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 name)
Extracts from node the attribute with the specified name.
if (node == null)
    return null;
Node attribute = node.getAttributes().getNamedItem(name);
return (attribute == null) ? null : attribute.getNodeValue().trim();
StringgetAttribute(Node node, String name)
get Attribute
return getAttribute(node, name, null);
ObjectgetAttribute(Node node, String name)
Extracts the value of the attribute from name.
NamedNodeMap map = node.getAttributes();
node = map.getNamedItem(name);
return (node != null) ? node.getNodeValue() : null;
StringgetAttribute(Node node, String name)
get Attribute
NamedNodeMap m = node.getAttributes();
if (m == null)
    return null;
Node att = m.getNamedItem(name);
if (att == null)
    return null;
return att.getNodeValue();
StringgetAttribute(Node node, String name)
get Attribute
NamedNodeMap attr = node.getAttributes();
for (int n = 0; n < attr.getLength(); n++) {
    Node attribute = attr.item(n);
    if (attribute.getNodeName().equals(name))
        return attribute.getNodeValue();
return "";
StringgetAttribute(Node node, String name, String defVal)
Returns an attribute of the specified tag with the name provided.
Node att = node.getAttributes().getNamedItem(name);
return att == null ? defVal : att.getNodeValue();
StringgetAttribute(Node node, String name, String defVal)
Returns an attribute of the specified tag with the name provided.
Node att = node.getAttributes().getNamedItem(name);
return att == null ? defVal : att.getNodeValue();
StringgetAttribute(Node pNode, String attrName)
get Attribute
try {
    NamedNodeMap name = pNode.getAttributes();
    if (name.getLength() > 0) {
        Node node = name.getNamedItem(attrName);
        if (node != null) {
            String attributeValue = name.getNamedItem(attrName).getNodeValue();
            return attributeValue;
        } else {
...
StringgetAttribute(Node pNode, String pName)
gets the value of the named attribute.
return getAttribute(pNode, pName, null);
StringgetAttribute(Node targetElem, String keyName, String defaultValue)
get Attribute
Node attribute = targetElem.getAttributes().getNamedItem(keyName);
if (attribute == null) {
    return defaultValue;
return attribute.getTextContent();