getAttribute function

String? getAttribute(
  1. List<XmlAttribute> attributes,
  2. String name, {
  3. String? def = '',
  4. String? namespace,
})

A utility method for getting an XML attribute with a default value.

Implementation

String? getAttribute(
  List<XmlAttribute> attributes,
  String name, {
  String? def = '',
  String? namespace,
}) {
  for (XmlAttribute attribute in attributes) {
    if (attribute.name.local == name) {
      return attribute.value;
    }
  }
  return def;
}