I am trying to get specific table (by id) from downloaded html and parse it I´ve tried few ways and my last code is
var url = @"C:\Users\name\Plocha\web.html";
var doc = new HtmlDocument();
doc.Load(url);
string data = "";
int i = 2;
foreach (HtmlNode table in doc.DocumentNode.SelectNodes("//table"))
{
Console.WriteLine($"Found: {table.Id}");
if (table.Id == "formTbl")
{
foreach (HtmlNode row in table.SelectNodes("//tr"))
{
foreach (HtmlNode cell in row.SelectNodes("td"))
{
if (i == 1)
{
data += $"Column:{cell.InnerText}";
i = 2;
}
else if (i == 2)
{
data += $"Row: {cell.InnerText}";
Console.WriteLine(data);
data = "";
i = 1;
}
}
}
}
else
{
Console.WriteLine("Not what we want");
}
}
The problem is that it print all tables from webpage even tho I have specified to continue only if id = formTbl.
How data looks on table (theres no Name of columns its just two rows, in first row is name of column and in second row is value)
