473,548 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Load string into mshtml object?

Can't seem to find anything that works for me. I have a small bit of
HTML that is stored in a string variable. I want to assign this string
to an mshtml object (IHTMLDocument2 I believe), so that I can traverse
the elements and attributes cleanly.
Does anybody know of a way to load this string into an mshtml object?
I would be beholdin'

Tks,
adwooley2

Oct 10 '06 #1
4 6046
Does anybody know of a way to load this string into an mshtml object?

Are you using .NET 2003 or 2005?

--

(O)enone
Oct 10 '06 #2
Using .NET 2005.

Oenone wrote:
Does anybody know of a way to load this string into an mshtml object?

Are you using .NET 2003 or 2005?

--

(O)enone
Oct 10 '06 #3
adwooley2 wrote:
Using .NET 2005.
I've done this using the new VS2005 WebBrowser control. It seemed to be a
little more complex than I was expecting, but still do-able.

Unfortunately the control didn't seem to like being instantiated from
scratch in code, so I had to create a form and place a WebBrowser control on
it. I don't know why this was necessary but it was the only way I could get
it to work. With this done (I've called my form WebBrowserForm, and the
WebBrowser control placed upon it is named WebBrowser), the following code
should do what you want:

\\\
Public Function HtmlDoc(ByVal HTML As String) As Windows.Forms.H tmlDocument

'Create an instance of the form containing the WebBrowser control
dim browserForm as New WebBrowserForm

'Set the document text to be our HTML
browserForm.Web Browser.Documen tText = HTML

'Wait until the document is loaded
Do Until browserForm.Web Browser.ReadySt ate = _
WebBrowserReady State.Loaded _
Or browserForm.Web Browser.ReadySt ate = _
WebBrowserReady State.Complete
Application.DoE vents()
Loop

'Return the document
Return browserForm.Web Browser.Documen t

End Function
///

You can then interrogate the DOM using the returned HtmlDocument object.

HTH,

--

(O)enone
Oct 11 '06 #4
Oenone,
Much appreciated.
Yes, I think that this is what I was looking for. And thanks for the
code - that makes it clearer.

Rgds,
adwooley2
Oenone wrote:
adwooley2 wrote:
Using .NET 2005.

I've done this using the new VS2005 WebBrowser control. It seemed to be a
little more complex than I was expecting, but still do-able.

Unfortunately the control didn't seem to like being instantiated from
scratch in code, so I had to create a form and place a WebBrowser control on
it. I don't know why this was necessary but it was the only way I could get
it to work. With this done (I've called my form WebBrowserForm, and the
WebBrowser control placed upon it is named WebBrowser), the following code
should do what you want:

\\\
Public Function HtmlDoc(ByVal HTML As String) As Windows.Forms.H tmlDocument

'Create an instance of the form containing the WebBrowser control
dim browserForm as New WebBrowserForm

'Set the document text to be our HTML
browserForm.Web Browser.Documen tText = HTML

'Wait until the document is loaded
Do Until browserForm.Web Browser.ReadySt ate = _
WebBrowserReady State.Loaded _
Or browserForm.Web Browser.ReadySt ate = _
WebBrowserReady State.Complete
Application.DoE vents()
Loop

'Return the document
Return browserForm.Web Browser.Documen t

End Function
///

You can then interrogate the DOM using the returned HtmlDocument object.

HTH,

--

(O)enone
Oct 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2222
by: Michael Hill | last post by:
If I have: <a href="javascript:myfunct('cool_links')" id="cool_links"> and I refer to it as: function myfunct(mylink) { document.getElementById }
8
13938
by: Jeff Johnson | last post by:
Hi, I've begun converting an ASP site over to .NET and I'm a novice at both the new platform as well as C#. I have a COM+ object that returns a string array when it is called. The size of the array can vary depending on the parameters passed. What I need to do is loop through the returned array and if applicable write the array...
10
3289
by: Wouter vanEck | last post by:
Hi, I need to find a way to read a html type string from a database and add it to a placeholder control on the page and then I need to be able to populate the fields that were in that html string at run time. The html string may look like this "<table><tr><td>First Name</td><td><input name=_firstname runat=server id=_firstname...
5
32132
by: Rajesh Kr Shukla | last post by:
Hi There, Can any one suggest me how to convert the string into object in VB.net. If you are familier with javascript you can use. var i = 1 eval("textbox" + i).value = "Hello World" What is the equivalent of this in VB.net Cheers..Rajesh
3
3976
by: Rich | last post by:
Hello, I am converting an app from VB6 to VB.Net and have encountered the following problem. I have the following loop which retrieves objects from a collection of objects. Dim entry As Domino.NotesViewEntry Dim obj As Object, str1 As String .... For Each obj In entry.ColumnValues.ToString
4
1897
by: Nikolay Petrov | last post by:
How can I access the MSHTML object in Internet Explorer, from my app? I don't want to use the IE Control and put it in my app. I want to be able to do things with the opened document in the allready started IE.
3
3389
by: rsine | last post by:
I have searched around a little and have yet to find a naming convention for the string builder object. I really do not want to use "str" since this is for string objects and thus could be confusing. Also, I would like a good source on the naming conventions to be used for other objects. It seems there are tons of sights with naming...
0
1173
by: John Olbert | last post by:
When I try to load an ActiveX object written in Vb6 that has been added to the Vs2005 tool list I receive this error-- "Failure to create component AxHost, The error message follows: 'System.Runtime.InteropServices.COMException(0x800A801D): A wrapper assembly is not registered for this type of library....". Is there a way to find out why...
6
7471
by: nramrits | last post by:
when i open form in a developer i'm getting err FRM-18108:faild to load a following objects. Source Module : PROG_UNIT.olb Source Object : PROC_RUN_REPORT this error comes perticular forms only , all other forms are working fine. pls anyone help me...
0
7438
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...
0
7707
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. ...
0
7951
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...
0
7803
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...
0
6036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3495
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...
1
1926
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
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.