Java XML Attribute Get getAttributeValue(Node node, String attributeName)

Here you can find the source of getAttributeValue(Node node, String attributeName)

Description

Get the attribute value of the node.

License

Open Source License

Parameter

Parameter Description
node the node
attributeName the name of the attribute

Return

the value of the attribute

Declaration

public static String getAttributeValue(Node node, String attributeName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {
    /**//from   w w  w  . ja  v  a2  s  .co  m
     * Get the attribute value of the node.
     * 
     * @param node
     *            the node
     * @param attributeName
     *            the name of the attribute
     * @return the value of the attribute
     */
    public static String getAttributeValue(Node node, String attributeName) {
        Node attribute = node.getAttributes().getNamedItem(attributeName);
        if (attribute != null) {
            return attribute.getNodeValue();
        } else {
            return null;
        }
    }
}

Related

  1. getAttributeValue(Node node, String attributeName)
  2. getAttributeValue(Node node, String attributeName)
  3. getAttributeValue(Node node, String attributeName)
  4. getAttributeValue(Node node, String attributeName)
  5. getAttributeValue(Node node, String attributeName)
  6. getAttributeValue(Node node, String attributeName, int defaultValue)
  7. getAttributeValue(Node node, String attrName)
  8. getAttributeValue(Node node, String attrName)
  9. getAttributeValue(Node node, String name)