I am getting the below error while parsing html table with c#
"An exception of type 'System.NullReferenceException' occurred in App_Web_k1wz0vym.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object."
at line " foreach (HtmlNode row in table.SelectNodes("tr"))"
Below is my code
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
string s = requestsTable.InnerHtml.ToString();
doc.LoadHtml(s);
foreach (HtmlNode table in doc.DocumentNode.SelectNodes("table"))
{
foreach (HtmlNode row in table.SelectNodes("tr"))
{
///This is the row.
foreach (HtmlNode cell in row.SelectNodes("th|td"))
{
Response.Write("<br>"+cell.InnerText);
}
}
}