views:

45

answers:

2

I was trying to use HtmlDocument and a given url to pull in the html contents of a website to use. However there is no constructor for HtmlDocument and it's Url property is readonly.

Is there any way to create an object that contains the entire DOM for a given url?

Thanks,
Matt

A: 

http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.aspx

John Saunders
Already looked that up. Doesn't say how to create an object based on the html retrieved from a url
Matt
Yeah, it does. It links to this: http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx
John Saunders
k yeah I missed that one. Thanks
Matt
A: 

I don't mean to point out the obvious but the first line in the documentation says - Provides top-level programmatic access to an HTML document hosted by the WebBrowser control.

This would explain why the URL property is read only. Not sure on why you need the HTML for visual or non visual purposes, but as a start you could set the URL property of the WebBrowser control, then grab the htmlDocument of the WebBrowser control after load.

This might be a cheap hack, if you're really after the clean html response from the server, and I am sure there are other non visual controls out there better to use than the WebBrowser control.

JL