You need to get a reference to the table (which you might be able to do using its css class if you haven't already accomplished this). Then you obtain the collection of rows and burrow into them using the ElementAt method:
var table = doc.DocumentNode.Descendants("table")
.Where(t => t.GetAttributeValue("class", "").Equals("tabcontent"))
.First();
var rows = table.Descendants("tr");
var thirdCellInThirdRow = rows.ElementAt(2).Descendants("td").ElementAt(2);
<div>@thirdCellInThirdRow.InnerText</div>
Member
564 Points
646 Posts
Using the HtmlAgilityPack to parse HTML and update the database
Jun 05, 2015 05:08 AM|dow7|LINK
I read mikesdotnetting's post (http://www.mikesdotnetting.com/article/273/using-the-htmlagilitypack-to-parse-html-in-asp-net) and i trying to parse a table which is inside another table which is inside another table...on a webpage.
How to get the data of:
3rd <td> on 3rd <tr>
3rd <td> on 4th <tr>
3rd <td> on 5th <tr>
3rd <td> on 6th <tr>
3rd <td> on 14th <tr>
3rd <td> on 15th <tr>
The html code is below:
All-Star
187718 Points
27198 Posts
Moderator
Re: Using the HtmlAgilityPack to parse HTML and update the database
Jun 05, 2015 07:07 AM|Mikesdotnetting|LINK
You need to get a reference to the table (which you might be able to do using its css class if you haven't already accomplished this). Then you obtain the collection of rows and burrow into them using the ElementAt method:
ASP.NET Tutorials | Learn Entity Framework Core | Learn Razor Pages