473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Writing an HTML string to an mshtml.Document

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
7 5879
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Charles Law | last post by:
Does anyone have a regex pattern to parse HTML from a stream? I have a well structured file, where each line is of the form <sometag someattribute='attr'>text</sometag> for example <SPAN...
0
by: gertjan.nospam | last post by:
Hello, I hope you can help me with this issue. I am trying to build an application in C# that converts text from XML with an XSL to a HTML file and prints it according to some printersettings...
5
by: Sunny | last post by:
Hi all, I have to get a HTML content of a given URL, to inspect links and images and to change something in there, and to save the result. I have done it already with: System.Net.WebClient source...
5
by: benc | last post by:
Hi Can some good soul help on this. I need to call jscript functions from C#. I have hosted a web control and displayed an html page successfully, but just can't find a way to call jscript...
8
by: McBeth | last post by:
Hi! I'm trying to call external HTML web page requiring several POST-ed parameters from C# Web form. Parameters should be set by Web form. Is it possible ? How can I do it ? Thanks in advance ...
8
by: copyco | last post by:
Is there a way to display formatted HTML in a Windows form? Or can I dynamically create an HTML file and then display that from a Windows Application? I can create a new HTML file in my project,...
9
by: Jay Kim | last post by:
Hi, We're implementing a Windows application using Visual Basic .NET. One of the key features we need to implement is that we should be able to get the accurate byte offset of user selected...
6
by: J Williams | last post by:
I'm using axWebBrowser control and HTML DOM in a VB .NET Windows application to create a new HTML document by cloning nodes. The function below is called from the axWebBrowser1_DocumentComplete...
10
by: Curtis | last post by:
Does anyone have any good examples of parsing WebPages in VB.Net. My application needs to get information from certain HTML tables and I haven't been able to find a good way to approach the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.