By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,501 Members | 1,678 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,501 IT Pros & Developers. It's quick & easy.

Writing an HTML string to an mshtml.Document

P: n/a
Hi,
I have being trying to get a grip of HTML data manipulation and am using the mshtml class and System.Net to retriver HTML pages.

Now as far as I can see, one can read HTML in different ways.

1. Using the WebBrowser and loading the HTML into the mshtml.HTMLDocument class and then step through the various tags (input, a), tables etc.
2. Use System.Net.WebRequest/Response to load the data into a HTML string using a Stream Reader.

Now there are times when I want to use the WebBrowser as it is handy for user input (and maybe show the user what is going on) and other times a more convenient method is to use the System.Net.WebRequest/Response metods.

However, I cannot for the life of me see how one can LOAD up an mshtml.HTMLDocument object with a plain HTML string that I may have got from using the System.Net.WebRequest/Response ....and vice versa...

Any clues ??

Cheers




Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Desmond

The document object exposes the IPersistStreamInit interface. The sequence
would be this:

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamInit interface from document
Call InitNew
Call Load
Wait for readyState to indicate "complete"

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
I have being trying to get a grip of HTML data manipulation and am using
the mshtml class and System.Net to retriver HTML pages.

Now as far as I can see, one can read HTML in different ways.

1. Using the WebBrowser and loading the HTML into the
mshtml.HTMLDocument class and then step through the various tags (input, a),
tables etc.
2. Use System.Net.WebRequest/Response to load the data into a HTML
string using a Stream Reader.

Now there are times when I want to use the WebBrowser as it is handy for
user input (and maybe show the user what is going on) and other times a more
convenient method is to use the System.Net.WebRequest/Response metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocument object with a plain HTML string that I may have got
from using the System.Net.WebRequest/Response ....and vice versa...

Any clues ??

Cheers

Nov 21 '05 #2

P: n/a
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamInit in VB.Net ?

I have trawled the Internet and MSDN to no avail....

I have tried Adding References, Imports system.x.y.z etc....and I still
cannot get that simple line

Dim ips as IPersistStreamInit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
Hi Desmond

The document object exposes the IPersistStreamInit interface. The sequence
would be this:

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamInit interface from document
Call InitNew
Call Load
Wait for readyState to indicate "complete"

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
I have being trying to get a grip of HTML data manipulation and am using
the mshtml class and System.Net to retriver HTML pages.

Now as far as I can see, one can read HTML in different ways.

1. Using the WebBrowser and loading the HTML into the
mshtml.HTMLDocument class and then step through the various tags (input,
a), tables etc.
2. Use System.Net.WebRequest/Response to load the data into a HTML
string using a Stream Reader.

Now there are times when I want to use the WebBrowser as it is handy
for user input (and maybe show the user what is going on) and other times
a more convenient method is to use the System.Net.WebRequest/Response
metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocument object with a plain HTML string that I may have got
from using the System.Net.WebRequest/Response ....and vice versa...

Any clues ??

Cheers


Nov 21 '05 #3

P: n/a
Hi Desmond

Sorry, here is one I made earlier

<code>
Public Enum HRESULT
S_OK = 0
S_FALSE = 1
E_NOTIMPL = &H80004001
E_INVALIDARG = &H80070057
E_NOINTERFACE = &H80004002
E_FAIL = &H80004005
E_UNEXPECTED = &H8000FFFF
End Enum

' IPersistStreamInit interface
<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersistStreamInit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRef pClassID As Guid)

<PreserveSig()> Function IsDirty() As Integer
<PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As HRESULT
<PreserveSig()> Function Save(ByVal pstm As UCOMIStream,
<MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig()> Function GetSizeMax(<InAttribute(), Out(),
MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As HRESULT
<PreserveSig()> Function InitNew() As HRESULT

End Interface
</code>

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamInit in VB.Net ?

I have trawled the Internet and MSDN to no avail....

I have tried Adding References, Imports system.x.y.z etc....and I still
cannot get that simple line

Dim ips as IPersistStreamInit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
Hi Desmond

The document object exposes the IPersistStreamInit interface. The
sequence would be this:

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamInit interface from document
Call InitNew
Call Load
Wait for readyState to indicate "complete"

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
I have being trying to get a grip of HTML data manipulation and am
using the mshtml class and System.Net to retriver HTML pages.

Now as far as I can see, one can read HTML in different ways.

1. Using the WebBrowser and loading the HTML into the
mshtml.HTMLDocument class and then step through the various tags (input,
a), tables etc.
2. Use System.Net.WebRequest/Response to load the data into a HTML
string using a Stream Reader.

Now there are times when I want to use the WebBrowser as it is handy
for user input (and maybe show the user what is going on) and other times
a more convenient method is to use the System.Net.WebRequest/Response
metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocument object with a plain HTML string that I may have got
from using the System.Net.WebRequest/Response ....and vice versa...

Any clues ??

Cheers



Nov 21 '05 #4

P: n/a
Hi Charles...
I am still none the wiser....what do I have to reference or to make it
simple...it still comes up with

D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95):
Attribute cannot be used on 'IPersistStreamInit'.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): 'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(96): Type
'InterfaceTypeAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'UCOMIStream' is not defined.

Show I so some import ???
Imports System.???????????

Sorry...I still haven't a clue why I have to put all this NON .Net code
in here ???

Cheers,

Dersmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:uY**************@TK2MSFTNGP15.phx.gbl...
Hi Desmond

Sorry, here is one I made earlier

<code>
Public Enum HRESULT
S_OK = 0
S_FALSE = 1
E_NOTIMPL = &H80004001
E_INVALIDARG = &H80070057
E_NOINTERFACE = &H80004002
E_FAIL = &H80004005
E_UNEXPECTED = &H8000FFFF
End Enum

' IPersistStreamInit interface
<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersistStreamInit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRef pClassID As Guid)

<PreserveSig()> Function IsDirty() As Integer
<PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As HRESULT
<PreserveSig()> Function Save(ByVal pstm As UCOMIStream,
<MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig()> Function GetSizeMax(<InAttribute(), Out(),
MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As HRESULT
<PreserveSig()> Function InitNew() As HRESULT

End Interface
</code>

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamInit in VB.Net ?

I have trawled the Internet and MSDN to no avail....

I have tried Adding References, Imports system.x.y.z etc....and I
still cannot get that simple line

Dim ips as IPersistStreamInit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
Hi Desmond

The document object exposes the IPersistStreamInit interface. The
sequence would be this:

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamInit interface from document
Call InitNew
Call Load
Wait for readyState to indicate "complete"

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
I have being trying to get a grip of HTML data manipulation and am
using the mshtml class and System.Net to retriver HTML pages.

Now as far as I can see, one can read HTML in different ways.

1. Using the WebBrowser and loading the HTML into the
mshtml.HTMLDocument class and then step through the various tags (input,
a), tables etc.
2. Use System.Net.WebRequest/Response to load the data into a HTML
string using a Stream Reader.

Now there are times when I want to use the WebBrowser as it is handy
for user input (and maybe show the user what is going on) and other
times a more convenient method is to use the
System.Net.WebRequest/Response metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocument object with a plain HTML string that I may have got
from using the System.Net.WebRequest/Response ....and vice versa...

Any clues ??

Cheers




Nov 21 '05 #5

P: n/a
Hi Desmond

The import you need is

Imports System.Runtime.InteropServices

Include the stuff I posted last time in a separate class file (for
neatness), and include it in your project with the import above.

..NET does not define the IPersistStreamInit interface, which is why you need
to define it yourself. If you were doing this in C++ you would just include
a header file containing the definition, but VB.NET doesn't have an
equivalent predefined version.

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:uj**************@TK2MSFTNGP14.phx.gbl...
Hi Charles...
I am still none the wiser....what do I have to reference or to make it
simple...it still comes up with

D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95):
Attribute cannot be used on 'IPersistStreamInit'.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): 'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(96): Type
'InterfaceTypeAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'UCOMIStream' is not defined.

Show I so some import ???
Imports System.???????????

Sorry...I still haven't a clue why I have to put all this NON .Net code
in here ???

Cheers,

Dersmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:uY**************@TK2MSFTNGP15.phx.gbl...
Hi Desmond

Sorry, here is one I made earlier

<code>
Public Enum HRESULT
S_OK = 0
S_FALSE = 1
E_NOTIMPL = &H80004001
E_INVALIDARG = &H80070057
E_NOINTERFACE = &H80004002
E_FAIL = &H80004005
E_UNEXPECTED = &H8000FFFF
End Enum

' IPersistStreamInit interface
<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersistStreamInit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRef pClassID As Guid)

<PreserveSig()> Function IsDirty() As Integer
<PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As HRESULT
<PreserveSig()> Function Save(ByVal pstm As UCOMIStream,
<MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig()> Function GetSizeMax(<InAttribute(), Out(),
MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As HRESULT
<PreserveSig()> Function InitNew() As HRESULT

End Interface
</code>

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamInit in VB.Net ?

I have trawled the Internet and MSDN to no avail....

I have tried Adding References, Imports system.x.y.z etc....and I
still cannot get that simple line

Dim ips as IPersistStreamInit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
Hi Desmond

The document object exposes the IPersistStreamInit interface. The
sequence would be this:

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamInit interface from document
Call InitNew
Call Load
Wait for readyState to indicate "complete"

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
I have being trying to get a grip of HTML data manipulation and am
using the mshtml class and System.Net to retriver HTML pages.

Now as far as I can see, one can read HTML in different ways.

1. Using the WebBrowser and loading the HTML into the
mshtml.HTMLDocument class and then step through the various tags
(input, a), tables etc.
2. Use System.Net.WebRequest/Response to load the data into a HTML
string using a Stream Reader.

Now there are times when I want to use the WebBrowser as it is handy
for user input (and maybe show the user what is going on) and other
times a more convenient method is to use the
System.Net.WebRequest/Response metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocument object with a plain HTML string that I may have
got from using the System.Net.WebRequest/Response ....and vice versa...

Any clues ??

Cheers




Nov 21 '05 #6

P: n/a
Hi Charles,
Many thanks for your patience....
Yes...this COM stuff is still a little bewildering to me...I came into VB at the .NET stage and haven't had much exposure to these concepts.
So effectively what is happening is we are creating the glue (interface) for the DOM (Document Object Model) ?

OK, I have included Imports System.Runtime.InteropServices and everything is OK apart from the line

<ComVisible(True), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> Public Interface IPersistStreamInit : Inherits IPersist
The : Inherits IPersist (at the end of the line) is still showing up as
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(98): Type 'IPersist' is not defined.

So this itself I imagine should just be an Interface such as
Public Interface IPersist

End Interface

However I am sure there should be some code in this ??? or is it referenced elsewhere ???

===============================================

Again many thanks for your own 'Persistance' with me ;-)

Cheers,

Desmond.



"Charles Law" <bl***@nowhere.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Desmond

The import you need is

Imports System.Runtime.InteropServices

Include the stuff I posted last time in a separate class file (for
neatness), and include it in your project with the import above.

.NET does not define the IPersistStreamInit interface, which is why you need
to define it yourself. If you were doing this in C++ you would just include
a header file containing the definition, but VB.NET doesn't have an
equivalent predefined version.

Charles


"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:uj**************@TK2MSFTNGP14.phx.gbl...
Hi Charles...
I am still none the wiser....what do I have to reference or to make it
simple...it still comes up with

D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95):
Attribute cannot be used on 'IPersistStreamInit'.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): 'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(96): Type
'InterfaceTypeAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'UCOMIStream' is not defined.

Show I so some import ???
Imports System.???????????

Sorry...I still haven't a clue why I have to put all this NON .Net code
in here ???

Cheers,

Dersmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:uY**************@TK2MSFTNGP15.phx.gbl...
Hi Desmond

Sorry, here is one I made earlier

<code>
Public Enum HRESULT
S_OK = 0
S_FALSE = 1
E_NOTIMPL = &H80004001
E_INVALIDARG = &H80070057
E_NOINTERFACE = &H80004002
E_FAIL = &H80004005
E_UNEXPECTED = &H8000FFFF
End Enum

' IPersistStreamInit interface
<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersistStreamInit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRef pClassID As Guid)

<PreserveSig()> Function IsDirty() As Integer
<PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As HRESULT
<PreserveSig()> Function Save(ByVal pstm As UCOMIStream,
<MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig()> Function GetSizeMax(<InAttribute(), Out(),
MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As HRESULT
<PreserveSig()> Function InitNew() As HRESULT

End Interface
</code>

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamInit in VB.Net ?

I have trawled the Internet and MSDN to no avail....

I have tried Adding References, Imports system.x.y.z etc....and I
still cannot get that simple line

Dim ips as IPersistStreamInit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
> Hi Desmond
>
> The document object exposes the IPersistStreamInit interface. The
> sequence would be this:
>
> Navigate to about:blank
> Wait for readyState to indicate "complete"
> Get IPersistStreamInit interface from document
> Call InitNew
> Call Load
> Wait for readyState to indicate "complete"
>
> HTH
>
> Charles
>
>
> "Desmond Cassidy" <De*************@T-Online.de> wrote in message
> news:%2****************@TK2MSFTNGP14.phx.gbl...
> Hi,
> I have being trying to get a grip of HTML data manipulation and am
> using the mshtml class and System.Net to retriver HTML pages.
>
> Now as far as I can see, one can read HTML in different ways.
>
> 1. Using the WebBrowser and loading the HTML into the
> mshtml.HTMLDocument class and then step through the various tags
> (input, a), tables etc.
> 2. Use System.Net.WebRequest/Response to load the data into a HTML
> string using a Stream Reader.
>
> Now there are times when I want to use the WebBrowser as it is handy
> for user input (and maybe show the user what is going on) and other
> times a more convenient method is to use the
> System.Net.WebRequest/Response metods.
>
> However, I cannot for the life of me see how one can LOAD up an
> mshtml.HTMLDocument object with a plain HTML string that I may have
> got from using the System.Net.WebRequest/Response ....and vice versa...
>
> Any clues ??
>
> Cheers
>
>
>
>
>




Nov 21 '05 #7

P: n/a
Desmond

Many apologies. I had not intended to leave that bit out. I didn't spot it
on the end of the line.

Here it is

<code>
' IPersist interface
<ComVisible(True), ComImport(),
Guid("0000010c-0000-0000-C000-000000000046"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersist
Sub GetClassID(ByRef pClassID As Guid)
End Interface
</code>

I could have done it another way, w/o needing the extra interface, but doing
it this way gives a more literal translation of the original.

I hope that covers it, but please don't worry about posting back if I have
missed anything else.

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
Hi Charles,
Many thanks for your patience....
Yes...this COM stuff is still a little bewildering to me...I came into
VB at the .NET stage and haven't had much exposure to these concepts.
So effectively what is happening is we are creating the glue (interface)
for the DOM (Document Object Model) ?

OK, I have included Imports System.Runtime.InteropServices and
everything is OK apart from the line

<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> Public
Interface IPersistStreamInit : Inherits IPersist
The : Inherits IPersist (at the end of the line) is still showing up as
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(98): Type
'IPersist' is not defined.

So this itself I imagine should just be an Interface such as
Public Interface IPersist
End Interface
However I am sure there should be some code in this ??? or is it referenced
elsewhere ???

===============================================
Again many thanks for your own 'Persistance' with me ;-)

Cheers,

Desmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Desmond

The import you need is

Imports System.Runtime.InteropServices

Include the stuff I posted last time in a separate class file (for
neatness), and include it in your project with the import above.

.NET does not define the IPersistStreamInit interface, which is why you
need
to define it yourself. If you were doing this in C++ you would just
include
a header file containing the definition, but VB.NET doesn't have an
equivalent predefined version.

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:uj**************@TK2MSFTNGP14.phx.gbl...
Hi Charles...
I am still none the wiser....what do I have to reference or to make it
simple...it still comes up with

D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95):
Attribute cannot be used on 'IPersistStreamInit'.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95):
'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(96): Type
'InterfaceTypeAttribute' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\ScreenScrape\WebUtilities.vb(104): Type
'UCOMIStream' is not defined.

Show I so some import ???
Imports System.???????????

Sorry...I still haven't a clue why I have to put all this NON .Net
code
in here ???

Cheers,

Dersmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:uY**************@TK2MSFTNGP15.phx.gbl...
Hi Desmond

Sorry, here is one I made earlier

<code>
Public Enum HRESULT
S_OK = 0
S_FALSE = 1
E_NOTIMPL = &H80004001
E_INVALIDARG = &H80070057
E_NOINTERFACE = &H80004002
E_FAIL = &H80004005
E_UNEXPECTED = &H8000FFFF
End Enum

' IPersistStreamInit interface
<ComVisible(True), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)> _
Public Interface IPersistStreamInit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRef pClassID As Guid)

<PreserveSig()> Function IsDirty() As Integer
<PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As HRESULT
<PreserveSig()> Function Save(ByVal pstm As UCOMIStream,
<MarshalAs(UnmanagedType.Bool)> ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig()> Function GetSizeMax(<InAttribute(), Out(),
MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As HRESULT
<PreserveSig()> Function InitNew() As HRESULT

End Interface
</code>

HTH

Charles
"Desmond Cassidy" <De*************@T-Online.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamInit in VB.Net ?

I have trawled the Internet and MSDN to no avail....

I have tried Adding References, Imports system.x.y.z etc....and I
still cannot get that simple line

Dim ips as IPersistStreamInit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere.com> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
> Hi Desmond
>
> The document object exposes the IPersistStreamInit interface. The
> sequence would be this:
>
> Navigate to about:blank
> Wait for readyState to indicate "complete"
> Get IPersistStreamInit interface from document
> Call InitNew
> Call Load
> Wait for readyState to indicate "complete"
>
> HTH
>
> Charles
>
>
> "Desmond Cassidy" <De*************@T-Online.de> wrote in message
> news:%2****************@TK2MSFTNGP14.phx.gbl...
> Hi,
> I have being trying to get a grip of HTML data manipulation and am
> using the mshtml class and System.Net to retriver HTML pages.
>
> Now as far as I can see, one can read HTML in different ways.
>
> 1. Using the WebBrowser and loading the HTML into the
> mshtml.HTMLDocument class and then step through the various tags
> (input, a), tables etc.
> 2. Use System.Net.WebRequest/Response to load the data into a HTML
> string using a Stream Reader.
>
> Now there are times when I want to use the WebBrowser as it is
> handy
> for user input (and maybe show the user what is going on) and other
> times a more convenient method is to use the
> System.Net.WebRequest/Response metods.
>
> However, I cannot for the life of me see how one can LOAD up an
> mshtml.HTMLDocument object with a plain HTML string that I may have
> got from using the System.Net.WebRequest/Response ....and vice
> versa...
>
> Any clues ??
>
> Cheers
>
>
>
>
>




Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.