parseBoolLiteral function
Parses a boolean literal from an XML element with the specified tagName
.
It searches for the element with the given tagName
and retrieves its inner text.
The inner text is then converted to lowercase and trimmed.
If the value is 'yes' or 'true', the function returns true, otherwise, it returns false.
If the element is not found or its value cannot be parsed as a boolean, it returns false.
Implementation
bool parseBoolLiteral(XmlElement element, String tagName) {
var v =
element.findElements(tagName).firstOrNull?.innerText.toLowerCase().trim();
if (v == null) return false;
return ['yes', 'true'].contains(v);
}