getElementAttributeStr function

String? getElementAttributeStr(
  1. Element element,
  2. String key
)

Returns element attribute with String key.

Implementation

String? getElementAttributeStr(Element element, String key) {
  var val = element.getAttribute(key);
  if (val != null) return val;

  key = key.trim().toLowerCase();

  for (var k in element.getAttributeNames()) {
    if (k.toLowerCase() == key) {
      return element.getAttribute(k);
    }
  }

  return null;
}