I want to extract data from HTMLTable row by row. But I'm facing problems in separating columns in the rows. The code I'm using below gives me each cell in a single line. But I want each row in 1 line then another. how can I do that?
HtmlNode table = doc.DocumentNode.SelectSingleNode("//table[" + tableCounter + "]");
foreach (var cell in table.SelectNodes(".//tr/td"))
{
string someVariable = cell.InnerText;
ReportFileWriter(someVariable);
}
tableCounter++;
This is the output I get from this code:
and the original table is like this:
and the output I want is to have spaces between columns:
Since I don't know your specific website, I used the following code to parse the
html table.
You need install Nuget -> HtmlAgilityPack. Code:
The first row in website:
The result you will get: