loading a url using mshtml

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
 
D

ddd

Thanks Charles! This works great.

Quick question what does IPersistStreamInit do?


thanks
 
C

Charles Law

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top