473,769 Members | 7,315 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.HTMLDocu ment class and then step through the various tags (input, a), tables etc.
2. Use System.Net.WebR equest/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.WebR equest/Response metods.

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

Any clues ??

Cheers




Nov 21 '05 #1
7 5908
Hi Desmond

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

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamI nit 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******** ********@TK2MSF TNGP14.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.HTMLDocu ment class and then step through the various tags (input, a),
tables etc.
2. Use System.Net.WebR equest/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.WebR equest/Response metods.

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

Any clues ??

Cheers

Nov 21 '05 #2
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamI nit 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 IPersistStreamI nit to compile ???

Confused...

Cheers,

Desmond.

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

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

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamI nit 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******** ********@TK2MSF TNGP14.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.HTMLDocu ment class and then step through the various tags (input,
a), tables etc.
2. Use System.Net.WebR equest/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.WebR equest/Response
metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocu ment object with a plain HTML string that I may have got
from using the System.Net.WebR equest/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

' IPersistStreamI nit interface
<ComVisible(Tru e), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IPersistStreamI nit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRe f 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(Unma nagedType.Bool) > ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig( )> Function GetSizeMax(<InA ttribute(), Out(),
MarshalAs(Unman agedType.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******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamI nit 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 IPersistStreamI nit to compile ???

Confused...

Cheers,

Desmond.

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

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

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamI nit 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******** ********@TK2MSF TNGP14.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.HTMLDocu ment class and then step through the various tags (input,
a), tables etc.
2. Use System.Net.WebR equest/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.WebR equest/Response
metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocu ment object with a plain HTML string that I may have got
from using the System.Net.WebR equest/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\Screen Scrape\WebUtili ties.vb(95):
Attribute cannot be used on 'IPersistStream Init'.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): 'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(96): Type
'InterfaceTypeA ttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.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******** ******@TK2MSFTN GP15.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

' IPersistStreamI nit interface
<ComVisible(Tru e), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IPersistStreamI nit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRe f 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(Unma nagedType.Bool) > ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig( )> Function GetSizeMax(<InA ttribute(), Out(),
MarshalAs(Unman agedType.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******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamI nit 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 IPersistStreamI nit to compile ???

Confused...

Cheers,

Desmond.

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

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

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamI nit 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******** ********@TK2MSF TNGP14.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.HTMLDocu ment class and then step through the various tags (input,
a), tables etc.
2. Use System.Net.WebR equest/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.WebR equest/Response metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocu ment object with a plain HTML string that I may have got
from using the System.Net.WebR equest/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 IPersistStreamI nit 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******** ******@TK2MSFTN GP14.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\Screen Scrape\WebUtili ties.vb(95):
Attribute cannot be used on 'IPersistStream Init'.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): 'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(96): Type
'InterfaceTypeA ttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.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******** ******@TK2MSFTN GP15.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

' IPersistStreamI nit interface
<ComVisible(Tru e), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IPersistStreamI nit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRe f 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(Unma nagedType.Bool) > ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig( )> Function GetSizeMax(<InA ttribute(), Out(),
MarshalAs(Unman agedType.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******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamI nit 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 IPersistStreamI nit to compile ???

Confused...

Cheers,

Desmond.

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

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

Navigate to about:blank
Wait for readyState to indicate "complete"
Get IPersistStreamI nit 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******** ********@TK2MSF TNGP14.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.HTMLDocu ment class and then step through the various tags
(input, a), tables etc.
2. Use System.Net.WebR equest/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.WebR equest/Response metods.

However, I cannot for the life of me see how one can LOAD up an
mshtml.HTMLDocu ment object with a plain HTML string that I may have
got from using the System.Net.WebR equest/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(Tru e), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > Public Interface IPersistStreamI nit : Inherits IPersist
The : Inherits IPersist (at the end of the line) is still showing up as
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.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******** ********@TK2MSF TNGP12.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 IPersistStreamI nit 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******** ******@TK2MSFTN GP14.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\Screen Scrape\WebUtili ties.vb(95):
Attribute cannot be used on 'IPersistStream Init'.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): 'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(96): Type
'InterfaceTypeA ttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.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******** ******@TK2MSFTN GP15.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

' IPersistStreamI nit interface
<ComVisible(Tru e), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IPersistStreamI nit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRe f 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(Unma nagedType.Bool) > ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig( )> Function GetSizeMax(<InA ttribute(), Out(),
MarshalAs(Unman agedType.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******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamI nit 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 IPersistStreamI nit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere. com> wrote in message
news:ef******** *****@TK2MSFTNG P14.phx.gbl...
> Hi Desmond
>
> The document object exposes the IPersistStreamI nit interface. The
> sequence would be this:
>
> Navigate to about:blank
> Wait for readyState to indicate "complete"
> Get IPersistStreamI nit 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******** ********@TK2MSF TNGP14.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.HTMLDocu ment class and then step through the various tags
> (input, a), tables etc.
> 2. Use System.Net.WebR equest/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.WebR equest/Response metods.
>
> However, I cannot for the life of me see how one can LOAD up an
> mshtml.HTMLDocu ment object with a plain HTML string that I may have
> got from using the System.Net.WebR equest/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(Tru e), ComImport(),
Guid("0000010c-0000-0000-C000-000000000046"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IPersist
Sub GetClassID(ByRe f 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******** ******@TK2MSFTN GP12.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(Tru e), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"),
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > Public
Interface IPersistStreamI nit : Inherits IPersist
The : Inherits IPersist (at the end of the line) is still showing up as
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.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******** ********@TK2MSF TNGP12.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 IPersistStreamI nit 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******** ******@TK2MSFTN GP14.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\Screen Scrape\WebUtili ties.vb(95):
Attribute cannot be used on 'IPersistStream Init'.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95):
'Guid'
cannot be used as an attribute because it is not a class.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComImport' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(95): Type
'ComVisible' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'InAttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(96): Type
'InterfaceTypeA ttribute' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(97): Type
'IPersist' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'MarshalAs' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'Out' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(106): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(104): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(102): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(105): Type
'PreserveSig' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.vb(103): Type
'UCOMIStream' is not defined.
D:\Visual Studio Private Projects\Screen Scrape\WebUtili ties.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******** ******@TK2MSFTN GP15.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

' IPersistStreamI nit interface
<ComVisible(Tru e), ComImport(),
Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IPersistStreamI nit : Inherits IPersist

' IPersist interface
Shadows Sub GetClassID(ByRe f 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(Unma nagedType.Bool) > ByVal fClearDirty As Boolean) As HRESULT
<PreserveSig( )> Function GetSizeMax(<InA ttribute(), Out(),
MarshalAs(Unman agedType.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******** ********@TK2MSF TNGP09.phx.gbl. ..
Hi Charles,
OK...I am missing something !!!

How do I reference IPersistStreamI nit 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 IPersistStreamI nit to compile ???

Confused...

Cheers,

Desmond.

"Charles Law" <bl***@nowhere. com> wrote in message
news:ef******** *****@TK2MSFTNG P14.phx.gbl...
> Hi Desmond
>
> The document object exposes the IPersistStreamI nit interface. The
> sequence would be this:
>
> Navigate to about:blank
> Wait for readyState to indicate "complete"
> Get IPersistStreamI nit 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******** ********@TK2MSF TNGP14.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.HTMLDocu ment class and then step through the various tags
> (input, a), tables etc.
> 2. Use System.Net.WebR equest/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.WebR equest/Response metods.
>
> However, I cannot for the life of me see how one can LOAD up an
> mshtml.HTMLDocu ment object with a plain HTML string that I may have
> got from using the System.Net.WebR equest/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
2592
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 CLASS='myclass'>A bit of text</SPAN>, or Just some text, without tags
0
1234
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 that can be made by an user interface. This application needs to run as an automatic process, so user intervention is not preferred.
5
2444
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 = new System.Net.WebClient(); StreamReader mr = null; try
5
5249
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 functions or set some var in the html. There are some sample code in C++ using IDispatch but these are beyond me. Looked at Tim Anderson's work on HTMLEditor but couldn't find any example on calling jscript function. Read somewhere that the browser...
8
10299
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 Adam
8
5406
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, but how do I reference it within my code, so I can manipulate it? Thanks.
9
2958
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 text in the file. We've been trying to use the RichTextBox control to load
6
8393
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 event using: Dim mNewDoc As mshtml.IHTMLDocument3 mNewDoc = NewDoc(axWebBrowser1.Document) Private Function NewDoc(ByVal mInputDoc As mshtml.IHTMLDocument3) As mshtml.IHTMLDocument3
10
29484
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 problem. I have researched RegularExpressions but have found it to be rather complicated for what I am attempting to accomplish. I was hoping that there would be some type of utility that would allow me to parse through the webpage in a tree like...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.