This is the discussion forum for the HtmlEditor. See also the
HtmlEditor home page, where you can download the control, and the
Documentation Wiki, a collaborative project for documenting the control.
Getting a DOM from an Url
Posted by:
Tim Anderson (---.server.ntl.com)
Date: Friday, 27-Dec-2002, 18:09:55
I've added a LoadUrl method to the utils class. The idea of this is to simplify getting an mshtml DOM from an URL, when you don't actually want to display the web page.
Here's some code I used in an ASP.Net application, using vb. It's a web form with two textboxes and a button. TextBox1 has an URL, TextBox2 is for output. What follows is the code for the button click. Note that I've not tried this under stress; for example, I'm not sure how well it would work if you wanted to use it in a spider application, or under heavy load.
thedoc = New mshtml.HTMLDocument()
onlyconnect.utils.LoadUrl(thedoc, Me.TextBox1.Text)
Dim timeout As DateTime = Now
While thedoc.readyState <> "complete"
System.Threading.Thread.Sleep(250)
If timeout.AddMinutes(1) < Now Then
Me.TextBox2.Text = "Timed out"
Exit Sub
End If
End While
Me.TextBox2.Text = thedoc.title