xmlText function

String? xmlText(
  1. KElement node, {
  2. required bool trim,
  3. int from = 0,
})

The text of node's first child and the text children right after it, optionally trimmed; null without children or when the first child isn't text. Port of XFormParser.getXMLText.

Implementation

String? xmlText(KElement node, {required bool trim, int from = 0}) {
  if (node.childCount == 0) return null;
  var text = node.textAt(from);
  if (text == null) return null;
  for (var i = from + 1; i < node.childCount && node.isText(i); i++) {
    text = text! + node.textAt(i)!;
  }
  return trim ? javaTrim(text!) : text;
}