loading a url using mshtml

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use MSHTML without the webbrowser and I am having a few
problems. Right now all I am trying to do is load an URL(html page) and
access its innerhtml.

What I have is:

Dim doc As mshtml.HTMLDocument = New mshtml.HTMLDocument()
Dim d1 As mshtml.IHTMLDocument4 = doc
Dim d2 As mshtml.IHTMLDocument4 = doc
d2.write("<html><body>test</body></html>")
d2.close()
MsgBox(d2.body.innerHTML)
d2 = d1.createDocumentFromUrl("http://www.msnbc.com", "")
MsgBox(d2.readystate)

It seems like I am able to load the url correct (ran a packet sniffer),
however, I cannot figure out how to detect that it has completed. I looked in
the web and there were some old examples using:

While d2.readyState <> "complete"
DoEvents
End While
But when I tried it started using 100% of the cpu and it never ended.


Any suggestions/ideas? Also can you point me to any good tutorials that
explain how to use of mshtml and vb.net

thanks
 
Thanks Charles! This works great.

Quick question what does IPersistStreamInit do?


thanks
 
As an interface it doesn't strictly *do* anything. It exposes methods for
initialising the DOM, and loading and saving a document via a stream.
Because mshtml supports so many methods, properties and events, it is a just
convenient way to group similar methods and attributes together.

HTH

Charles
 
Back
Top