I need kind favor to signoff the task. I want to count the tag using htmlaglitypack. I tried to count the tag by using htmlcollection node. But getting
"Object reference not set to an instance of an object"
In the line foreach condition. Can anyone of them rectify the issue why I'm getting like that?
My code is posted below:
public void XmlPPC(string rights)
{
int count = 0;
try
{
MessageBox.Show(rights);
using (FileStream fs = File.Open(rights,
FileMode.Open,
FileAccess.Read,
FileShare.ReadWrite))
using (BufferedStream bs = new BufferedStream(fs))
using (StreamReader sr = new StreamReader(bs))
{
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(sr);
HtmlNodeCollection right = doc.DocumentNode.SelectNodes("//copyrightLine");
foreach (HtmlNode logan in right)
{
count = count + 1;
MessageBox.Show("cnt" + count.ToString());
}
// snip...
}
}
catch (Exception f)
{
log = log + "\r\n" + f.ToString();
}
}