getAttribute method
Return the attribute value with the given name
, or null
.
Both name
and namespace
can be a specific String; or '*'
to match
anything. If no namespace
is provided, the fully qualified name is
compared; otherwise only the local name is considered.
For example:
element.getAttribute('xsd:name')
returns the first attribute value with the fully qualified attribute namexsd:name
.element.getAttribute('name', namespace: '*')
returns the first attribute value with the local attribute namename
no matter the namespace.element.getAttribute('*', namespace: 'http://www.w3.org/2001/XMLSchema')
returns the first attribute value within the provided namespace URI.
Implementation
@override
String? getAttribute(String name, {String? namespace}) =>
getAttributeNode(name, namespace: namespace)?.value;