Java XML Attribute Get getAttributeValue(final Element element, final String attributeName)

Here you can find the source of getAttributeValue(final Element element, final String attributeName)

Description

Get XML element's attribute value

License

Open Source License

Parameter

Parameter Description
element XML element
attributeName Attribute name

Return

Attribute value

Declaration

public static String getAttributeValue(final Element element, final String attributeName) 

Method Source Code

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

import org.w3c.dom.Attr;

import org.w3c.dom.Element;

public class Main {
    /**/*from   www .  j ava  2 s .c  o m*/
     * Get XML element's attribute value
     * @param element XML element
     * @param attributeName Attribute name
     * @return Attribute value
     */
    public static String getAttributeValue(final Element element, final String attributeName) {
        String attributeValue = "";

        Attr attribute = element.getAttributeNode(attributeName);
        if (null != attribute) {
            attributeValue = attribute.getValue();
        }

        return attributeValue;
    }
}

Related

  1. getAttributeValue(Element element, String name)
  2. getAttributeValue(Element element, String name)
  3. getAttributeValue(Element element, String tag)
  4. getAttributeValue(final Element e, final String attributeName)
  5. getAttributeValue(final Element el, final String attrName)
  6. getAttributeValue(final Element element, final String name)
  7. getAttributeValue(final Node candidate, final String attributName)
  8. getAttributeValue(final Node iNode, final String iAttributeName)
  9. getAttributeValue(final Node node, final String attributeName)