Java Utililty Methods XML Attribute By QName

List of utility methods to do XML Attribute By QName

Description

The list of methods to do XML Attribute By QName are organized into topic(s).

Method

AttrgetAttribute(Element el, QName attributeName)
The method returns attribute node by the given qname.
if (el == null)
    throw new IllegalArgumentException("Element can not be NULL");
if (attributeName == null)
    throw new IllegalArgumentException("Attribute name can not be NULL");
String nsURI = attributeName.getNamespaceURI();
String localPart = attributeName.getLocalPart();
if (localPart == null)
    throw new IllegalArgumentException("Local part of the attribute name can not be NULL");
...
StringgetAttribute(Element xml, QName qname)
get Attribute
String uri = qname.getNamespaceURI();
String name = qname.getLocalPart();
String value = xml.getAttributeNS(uri, name);
if (value != null && value.length() == 0)
    return null;
return value;
QNamegetAttributeAsQName(XMLStreamReader reader, String name)
Returns the QName value of an attribute.
String qname = reader.getAttributeValue(null, name);
return getValueAsQName(reader, qname);
StringgetAttributeValue(final XMLStreamReader streamReader, final QName name)
Get the value of the specified attribute.
return streamReader.getAttributeValue(name.getNamespaceURI(), name.getLocalPart());
QNamegetAttributeValueAsQName(final Element el, final String attrName)
get Attribute Value As Q Name
return getAttributeValueAsQName(el, new QName(attrName));