getAttributeNode method
Return the attribute node 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.getAttributeNode('xsd:name')
returns the first attribute node with the fully qualified attribute namexsd:name
.element.getAttributeNode('name', namespace: '*')
returns the first attribute node with the local attribute namename
no matter the namespace.element.getAttributeNode('*', namespace: 'http://www.w3.org/2001/XMLSchema')
returns the first attribute node within the provided namespace URI.
Implementation
@override
XmlAttribute? getAttributeNode(String name, {String? namespace}) {
final tester = createNameMatcher(name, namespace);
for (final attribute in attributes) {
if (tester(attribute)) {
return attribute;
}
}
return null;
}