matches method

bool matches(
  1. XmlStartElementEvent event,
  2. XmlTextEvent? contentEvent
)

Checks if the given event matches the removal criteria.

Implementation

bool matches(XmlStartElementEvent event, XmlTextEvent? contentEvent) {
  if (event.name != tag) return false;
  if (content != null &&
      (contentEvent == null || contentEvent.value.trim() != content)) {
    return false;
  }
  if (attributes != null) {
    final eventAttrs = Map.fromEntries(
      event.attributes.map((e) => MapEntry(e.name, e.value)),
    );
    for (final entry in attributes!.entries) {
      if (eventAttrs[entry.key] != entry.value) {
        return false;
      }
    }
  }
  return true;
}