removeAttribute static method

XmlElement? removeAttribute(
  1. XmlElement? node,
  2. String tag
)

Changes an XmlElement attribute value

Implementation

static XmlElement? removeAttribute(XmlElement? node, String tag) {
  try {
    if (node != null) {
      var attribute = node.attributes
          .firstWhereOrNull((attribute) => attribute.name.local == tag);
      //var attribute = node.attributes.firstWhereOrNull((attribute) => attribute.name.local == tag || attribute.name.local.toLowerCase() == tag || attribute.name.local.toUpperCase() == tag);
      if (attribute != null) node.attributes.remove(attribute);
    }
  } catch (e) {
    Log().exception(e,
        caller: 'xml.dart => removeAttribute({XmlElement node, String tag})');
  }
  return node;
}