parse static method

Map<String, String?> parse(
  1. String input
)

Parses XML content from the input string and returns a dictionary of configuration key-value pairs.

The method processes XML elements and attributes:

  • Element hierarchies create colon-delimited keys
  • Attributes become key-value pairs
  • The 'Name' attribute creates a hierarchical level
  • Repeated elements are indexed numerically (0, 1, 2, ...)
  • Empty elements map to empty strings

Throws FormatException if:

  • A duplicate key is encountered
  • XML namespaces are used

Implementation

static Map<String, String?> parse(String input) {
  final data = LinkedHashMap<String, String?>(
    equals: (a, b) => a.toLowerCase() == b.toLowerCase(),
    hashCode: (k) => k.toLowerCase().hashCode,
  );

  final document = XmlDocument.parse(input);

  // Process the root element
  _processElement(document.rootElement, '', data);

  return data;
}