This project has moved. For the latest updates, please go here.

Fumbling with parsing HTML table

Topics: User Forum
Mar 21, 2014 at 7:27 PM
I'm struggling to get the <tr> rows and <td> cell values out of an HTML table. I got the table out of the doc by using:
HtmlNodeCollection tables = doc.DocumentNode.SelectNodes("//table");
And then getting the 4th table (the one I want) using:
HtmlNodeCollection rows = tables[3].SelectNodes("tr");
The rows.count is 635.

And now, this code just seems to give me the first row. I can't get the other 364 rows for some reason. I've tried various foreach loops, too. Just flailing. :)
            for (int j = 0; j < rows.Count; j++)
                HtmlNodeCollection cols = rows[j].SelectNodes("td");
                //HtmlNodeCollection cols = row.SelectNodes("/td");
                for (int i = 0; i <= cols.Count; i++)
                    this.textBoxPageHTML.AppendText("column " + i.ToString());