For the following HTML:
<table>
<tbody>
<tr valign="TOP">
<td align="LEFT"><b>Licensee Name:</b></td>
<td align="LEFT">Some-last-name Some-first-name</td>
</tr>
<tr valign="TOP">
<td align="LEFT"><b>License Type:</b></td>
<td align="LEFT">Optometrist (OPT)</td>
</tr>
.
.
.
</tbody>
</table>
The following code produces an empty collection of Elements:
Elements rows = docOptometristDetail.select("body > table ~ tr");
But this code works:
tables = docOptometristDetail.select("body > table");
Elements rows = tables.select("tr");
I was expecting the tilde operator:
table ~ tr
to find the <table>
element, skip the <tbody>
element and build a collection of the <tr>
elements.
Have I uncovered a weakness in Jsoup's selector syntax parser or am I attempting to violate some operator precedence rules?
I tried (body > table) ~ tr
but that throws a SelectorParseException
.
Is there a way to do this selection (i.e. getting an Elements
collection of <tr>
elements) with a single selector expression?