GetAttributeWithNamespace method

String? GetAttributeWithNamespace(
  1. String attributeName,
  2. String namespace
)

Implementation

String? GetAttributeWithNamespace(String attributeName, String namespace) {
  final resolvedNamespaces = <String, String>{};
  for (final namespaces in _namespaces) {
    for (final namespace in namespaces.entries) {
      resolvedNamespaces[namespace.key] = namespace.value;
    }
  }
  var namespacePrefix = resolvedNamespaces.keys.firstWhereOrNull(
    (prefix) => resolvedNamespaces[prefix] == namespace,
  );
  return _unescapeAttribute(
    (_current as XmlStartElementEvent).attributes
        .firstWhereOrNull(
          (attr) =>
              attr.localName == attributeName &&
              attr.namespacePrefix == namespacePrefix,
        )
        ?.value,
  );
}