I have this piece of code:
string x = textBox1.Text;
string[] list = x.Split(';');
foreach (string u in list)
{
string url = "http://*********/index.php?n=" + u;
webBrowser1.Navigate(url);
webBrowser1.Document.GetElementsByTagName("META");
}
and I’m trying to get the <META> tags to output to a message box, but when I test it out, I keep getting this error:
Object reference not set to an instance of an object.
Your problem is that you’re accessing the
Documentobject before the document has loaded –WebBrowsers are asynchronous. Just parse the HTML using a library like the HTML Agility Pack.Here’s how you might get the
<meta>tags using the HTML Agility Pack. (Assumesusing System.Net;andusing HtmlAgilityPack;.)