Maybe reverse this into

if (e is Html.LIElement) {
  data.add(e.text);
}