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:
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. :)
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());
this.textBoxPageHTML.AppendText(cols[i].InnerText);
this.textBoxPageHTML.AppendText(System.Environment.NewLine);
}
}