Given a list of column header names, I want to parse an HTML table using HTMLAgilityPack, to retrieve all table data under that column.
I can't seem to figure out how to apply LINQ towards this.
I am grabbing the table header column names like so...
//Select HTML Table
var table = htmlDoc.DocumentNode.SelectSingleNode("//table");
List<string> headerColumnNames = new List<string>();
foreach (HtmlNode tableHeader in table.SelectNodes("tr[1]/th"))
{
headerColumnNames.Add(tableHeader.InnerText.Trim());
}
(If you know how to do this in LINQ please feel free to give me an example).
Now I want to do something like
foreach (string name in headerColumnNames){
//SELECT all table data
//WHERE the table column.name == name
//return a List of strings representing each cell value
}
I can't seem to figure out how to accomplish this using LINQ.