configurationsFromXml<T> function

List<T>? configurationsFromXml<T>(
  1. XmlElement? xml,
  2. String elementName,
  3. T parse(
    1. XmlElement? xml
    ), {
  4. String? wrapperName,
  5. String? wrapperItemName,
})

The configurations of a notification configuration are the direct children of the <NotificationConfiguration> element, one element per configuration.

A server that wraps them in an element of their own is read as well, so a document written by an older version of this package is not lost.

Implementation

List<T>? configurationsFromXml<T>(
  XmlElement? xml,
  String elementName,
  T Function(XmlElement? xml) parse, {
  String? wrapperName,
  String? wrapperItemName,
}) {
  if (xml == null) return null;
  final configurations = <T>[];
  for (final child in xml.findElements(elementName)) {
    configurations.add(parse(child));
  }
  if (configurations.isEmpty && wrapperName != null) {
    final wrapper = getProp(xml, wrapperName);
    if (wrapper != null) {
      for (final child in wrapper.findElements(
        wrapperItemName ?? elementName,
      )) {
        configurations.add(parse(child));
      }
    }
  }
  return configurations;
}