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