Hello, I have a webbrowser control. I navigate it to some address. When it loaded i want to pick only urls from inside this codes. Is it possible to handle the html like xml? If it is possible i can use othe DOM properties too. Any xml like ingredient container object to pass the html into it? Thank you.
views:
31answers:
2
+1
A:
Sounds like you need to use the HTML agility pack
Also see this other stack overflow question:
DoctaJonez
2010-08-22 19:24:33
A:
Yes, you can use MSHTML to navigate the DOM. You would need to add a reference to Microsoft.mshtml
in your project. An example of using it to get all links in a document would be:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlDocument doc = webBrowser1.Document;
foreach (HtmlElement element in doc.Links)
{
HTMLAnchorElement link = (HTMLAnchorElement) element.DomElement;
Debug.WriteLine(link.href);
}
}
Garett
2010-08-24 06:03:08