getValueFromNode<T> method

T? getValueFromNode<T>(
  1. String tag, [
  2. T parser(
    1. string i
    )?
])

Returns the text value from a specific child node with the given tag.

If the child node does not exist or if there are multiple child nodes with the same tag, it returns null.

Implementation

T? getValueFromNode<T>(String tag, [T Function(string i)? parser]) {
  var x = findElements(tag).singleOrNull?.innerText;
  if (x == null) return null;
  try {
    if (parser == null) return changeTo(x);
    return parser(x);
  } catch (e) {
    consoleLog("Error parsing $x", error: e);
    return null;
  }
}