Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72473

Jsoup - how to find out elements size

$
0
0

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.


Viewing all articles
Browse latest Browse all 72473

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>