I have a web-page:
It seems you have hit a known issue from Jsoup (see luksch's answer for details). However, here is a workaround working on Jsoup 1.8.3
.
table#timetable > tbody > tr > td.time
String html = "<table id=\"timetable\" class=\"table gradient-table\">\n<tbody>\n <tr>\n <td class=\"time\">\n <div>10:30 12:05</div>\n </td>\n <td class=\"time\">\n <div>12:30 14:05</div>\n </td>\n <td class=\"time\">\n <div>12:30 14:05</div>\n </td>\n <td class=\"time\">\n <div>14:30 16:05</div>\n </td>\n <td class=\"time\">\n <div>16:30 18:05</div>\n </td>\n </tr>\n</tbody>\n</table>";
Document doc = Jsoup.parse(html);
for (Element elt : doc.select("table#timetable > tbody > tr > td.time")) {
System.out.println(elt.text());
}
10:30 12:05
12:30 14:05
12:30 14:05
14:30 16:05
16:30 18:05
Tested on Jsoup 1.8.3
You came across a known bug in JSoup 1.8.2 & JSoup 1.8.3. See issue #614 and #664
To avoid this you should downgrade to Jsoup version 1.8.1 if possible or make sure to not use the select method of the Elements (plural!) class. CSS selectors on single elements or the whole dolument seem to be not affected, so you can also go with the solution of @Stephan.