adwooley2 wrote:
Using .NET 2005.
I've done this using the new VS2005 WebBrowser control. It seemed to be a
little more complex than I was expecting, but still do-able.
Unfortunately the control didn't seem to like being instantiated from
scratch in code, so I had to create a form and place a WebBrowser control on
it. I don't know why this was necessary but it was the only way I could get
it to work. With this done (I've called my form WebBrowserForm, and the
WebBrowser control placed upon it is named WebBrowser), the following code
should do what you want:
\\\
Public Function HtmlDoc(ByVal HTML As String) As Windows.Forms.HtmlDocument
'Create an instance of the form containing the WebBrowser control
dim browserForm as New WebBrowserForm
'Set the document text to be our HTML
browserForm.WebBrowser.DocumentText = HTML
'Wait until the document is loaded
Do Until browserForm.WebBrowser.ReadyState = _
WebBrowserReadyState.Loaded _
Or browserForm.WebBrowser.ReadyState = _
WebBrowserReadyState.Complete
Application.DoEvents()
Loop
'Return the document
Return browserForm.WebBrowser.Document
End Function
///
You can then interrogate the DOM using the returned HtmlDocument object.
HTH,
--
(O)enone