Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Fumbling with parsing HTML table

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

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>