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.
Asked
Active
Viewed 2,129 times
3
-
Din't exactly understand what you are trying to do. Could you explain a little more? – Roopesh Shenoy Aug 22 '10 at 19:27
-
Yes, i have a little project. On the form there is a webbrowser control. When it loaded with an url, i want to pickup url ( tags) addresses and put them into a collection, or write them into a textarea. To do these, i would like to use it like xml. Should i then convert the html into xhtml or something else? Now i am searching on HTML Agility Pack. Any native methods wellcome. Thank you PS: Sorry for my poor English. – Caglar Or Aug 22 '10 at 19:56
2 Answers
4
Sounds like you need to use the HTML agility pack
Also see this other stack overflow question:
C# Is there a LINQ to HTML, or some other good .Net HTML manipulation API?

Doctor Jones
- 21,196
- 13
- 77
- 99
1
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
- 16,632
- 5
- 55
- 63