I am confused with jsoup API. My code parses a table with 4 cells. But I found an occurence where three cells are merged into the single one and my code fails there because the child at position 3 does not exist.
String sMminutesLeft = row.child(3).text();
The element.child(x)
returns a filtered list of child elements, e.g. only tags, not text nodes. But element.childNodesCount()
will return a count of all elements including text nodes. I expected 4 but I receive 9 (lots of newlines are included).
I found element.getElementsByTag("TD")
returning Elements
object. This object acts like a container but it does not have any size()
method.
How can I safely find out number of TDs under the current TR element? Implementing NodeVisitor
seems like overkill to me.