parseAttributes static method

Map<String, dynamic> parseAttributes(
  1. String input
)

Parses attributes from the input xml string

Implementation

static Map<String, dynamic> parseAttributes(String input) {
  final doc = XmlDocument.parse(
          '<attributes>${XmlUtils.unescape(input)}</attributes>')
      .rootElement;
  final attr = {};
  doc.children.whereType<XmlElement>().forEach((element) {
    final name = element.findElements('name').first.innerText.trim();
    dynamic value = element.findElements('value').first.innerText.trim();
    value = num.tryParse(value as String) ?? value;

    value = (value == 'true' || value == 'false') ? value == 'true' : value;

    attr[name] = value;
  });
  return attr as Map<String, dynamic>;
}