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(final Node node, final String name)
Returns the value of a named attribute of a given node.
try {
    return node.getAttributes().getNamedItem(name).getNodeValue();
} catch (NullPointerException e) {
    return null;
StringgetAttributeValue(final XMLStreamReader reader, final String name)
Fetches the attribute name from the current elements namespace.
return reader.getAttributeValue(null, name);
StringgetAttributeValue(NamedNodeMap attributes, String name)
get Attribute Value
String value = null;
Node node = attributes.getNamedItem(name);
if (node != null) {
    value = node.getNodeValue();
return value;
StringgetAttributeValue(Node element, String attribute)
get Attribute Value
return element.getAttributes().getNamedItem(attribute).getNodeValue();
StringgetAttributeValue(Node element, String attribute)
get Attribute Value
return element.getAttributes().getNamedItem(attribute).getNodeValue();
StringgetAttributeValue(Node htmlForm, String attributeName)
get Attribute Value
Node item = htmlForm.getAttributes().getNamedItem(attributeName);
return item == null ? null : item.getNodeValue();
StringgetAttributeValue(Node iNode, String iAttributeName)
This method returns the value of the attribute that matches the attribute name (iAttributeName) and namepace (iNamespaceForAttr) in the node.
Logger.getLogger("org.adl.util.debug.validator").entering("DOMTreeUtility", "getAttributeValue()");
Logger.getLogger("org.adl.util.debug.validator").info("Parent Node: " + iNode.getLocalName());
Logger.getLogger("org.adl.util.debug.validator").info("Node being searched for: " + iAttributeName);
String result = "";
Attr theAttribute = getAttribute(iNode, iAttributeName);
if (theAttribute != null) {
    result = theAttribute.getValue();
return result;
StringgetAttributeValue(Node n, String name)
Lookup an attribute from a DOM node.
NamedNodeMap nm = n.getAttributes();
for (int i = 0; i < nm.getLength(); i++) {
    Node node = nm.item(i);
    if (name.equals(node.getNodeName())) {
        return node.getNodeValue();
return "";
...
StringgetAttributeValue(Node n, String name)
Lookup an attribute from a DOM node.
NamedNodeMap nm = n.getAttributes();
for (int i = 0; i < nm.getLength(); i++) {
    Node node = nm.item(i);
    if (name.equals(node.getNodeName())) {
        return node.getNodeValue();
return "";
...
StringgetAttributeValue(Node n, String nodePath, String attrName)
get Attribute Value
String attrValue = null;
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr3 = xpath.compile(nodePath + "/@" + attrName);
Object result3 = expr3.evaluate(n, XPathConstants.NODESET);
NodeList nodes3 = (NodeList) result3;
for (int i = 0; i < nodes3.getLength(); i++) {
    attrValue = nodes3.item(i).getNodeValue();
...