Java XML Attribute Get getAttributeValue(StartElement startElement, String attributeName)

Here you can find the source of getAttributeValue(StartElement startElement, String attributeName)

Description

Gets the value of a given attribute

License

Open Source License

Parameter

Parameter Description
startElement a parameter
attributeName a parameter

Declaration

private static String getAttributeValue(StartElement startElement, String attributeName) 

Method Source Code


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

import javax.xml.namespace.QName;

import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.StartElement;

public class Main {
    /**/*from  w  w w. ja  v a  2s . c om*/
     * Gets the value of a given attribute
     * @param startElement
     * @param attributeName
     * @return
     */
    private static String getAttributeValue(StartElement startElement, String attributeName) {
        String value = null;
        Attribute idAttr = startElement.getAttributeByName(new QName(attributeName));
        if (idAttr != null) {
            value = idAttr.getValue();
        }
        return value;
    }
}

Related

  1. getAttributeValue(Node node, String name, String defaultValue)
  2. getAttributeValue(Node sNode, String attribName)
  3. getAttributeValue(Node sNode, String attribName)
  4. getAttributeValue(NodeList elements, String attributeName)
  5. getAttributeValue(StartElement element, String namespaceURI, String localPart)
  6. getAttributeValue(String attributeName, Node xmlNode)
  7. getAttributeValueAsBoolean(Attr attribute)
  8. getAttributeValueAsBoolean(Element el, String attrName)
  9. getAttributeValueAsDouble(Node node, String attributeName)