0
static public void main( String[] args ) {
   Document playerpage =
      Jsoup.connect("http://en.wikipedia.org/wiki/Diego_Forl%C3%A1n").get();
   Elements table = playerpage.getElementsByTag("table").select("table.infobox");
   Elements ind = table.select("tr:contains(Club information)");

ご覧のとおり、次のテキストを含むテーブルの行が正常に選択されましたClub information

次の検索で番号を使用したいので、この要素の行インデックスを返すにはどうすればよいですか?

4

1 に答える 1

1
    Document playerpage = Jsoup.connect("http://en.wikipedia.org/wiki/Diego_Forl%C3%A1n").get();
    Elements table = playerpage.select("table.infobox > tbody > tr");
    int rowCount = 0;
    for (Element e : table) {
        if (e.text().contains("Club information")) {
            System.out.println("Row: " + rowCount);
            System.out.println(e);
        }
        rowCount++;
    }
于 2012-05-24T12:30:07.210 に答える