开发者

jsoup second element instead of first()

I have translated the PHP Simple HTML DOM query:

$article->find('td[id$=tdDescription] div a', 1)->plaintext;

to the jsoup query:

resultRow.select("td[id$=tdDescription] > div > a").first().text());

as you can see I am acessing the second (1) result in PHP, currently in jsoup with the .first() I am acce开发者_如何学运维ssing the first result (0) but I would also like to access the second result (1), how would I do that?


Use Elements#get() instead. This allows accessing elements by index.

resultRow.select("td[id$=tdDescription] > div > a").get(1).text();


Use td[id$=tdDescription] > div > a:eq(2)selector.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜