12

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 accessing the first result (0) but I would also like to access the second result (1), how would I do that?

Dominik
  • 4,718
  • 13
  • 44
  • 58

2 Answers2

21

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

resultRow.select("td[id$=tdDescription] > div > a").get(1).text();
Michal_Szulc
  • 4,097
  • 6
  • 32
  • 59
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
3

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

Afroz Shaikh
  • 362
  • 4
  • 18