English 中文(简体)
在 jsoup 中查找选定行元素的行索引
原标题:Find the row index of a selected row element in jsoup
  • 时间:2012-05-24 01:51:46
  •  标签:
  • row
  • jsoup
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

我要在下次搜索时使用该号码, 如何返回此元素的行索引?

最佳回答
    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++;
    }
问题回答

暂无回答




相关问题
(PHP & mySQL) Treat rows as columns

I am working on PHP & mySQL based website. I am trying to setup the Settings page in administration panel where I can enter different settings to manage the site. The settings can range upto 100 ...

jQuery Delete From Table

This code does following: Click on "Delete" in item row -> deletes item row Click on "Delete" in category row -> deletes category row and all item rows (in all table) Need it to do following: Click ...

Best Way to Ajax-Control Table Rows

I want to be able to print out a table with x rows and about 10 columns. However, I want to be able to select rows in the table as if it was a multiple select box. Selecting the row of the table will ...

Removing a row from an Excel sheet with Apache POI HSSF

I m using the Apache POi HSSF library to import info into my application. The problem is that the files have some extra/empty rows that need to be removed first before parsing. There s not a ...

jqgrid custom row colors

How can I set the background-color of an entire row (not just cell) using the custom formatter?

How to programmatically select top row of JQGrid?

How does one programmatically select the top row of a JQGrid. I want to have the top row already selected when it is opened on the page. My grid is sorted by a descriptive column so the first row s id ...

热门标签