473,586 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple but difficult to find solution for loading HTML into object

Joe
Hi, I have a simple thing I need to do but just doesn't work in VB.NET.
I have a string with HTML code and I want to load it into a HTMLDocument
object or something similiar to it so I can access the the tags and tags
value (<td> <table>, etc) by code.

But it just doesn't work in VB.NET but works in VB6. Please someone just
show me the right way to do this simple thing.

My code (which doesnt work):

Dim str0 as string = "<html> <body> Hi</body></html>
Dim doc as HTMLDocument = new HTMLDocument

doc.body.innerH TML = str0
''' This doesn't work. How can I load HTML into an HTML like
object??? Please help and thanks in advance


J.

Feb 8 '06 #1
3 3794
So long as the HTML is 'well formed' you will be able to load it into an
XmlDocument object which provides all the functionality you will need for
finding and interrogating elements.

Unfortunately, a number of web browsers (IE included) will quite happily
render HTML that is not 'well formed' and this allows HTML writers to be a
bit lazy in this respect.

If you are writing the HTML yourself then you can ensure that it is 'well
formed'.
"Joe" <jo*******@yaho o.com> wrote in message
news:ud******** *****@TK2MSFTNG P11.phx.gbl...
Hi, I have a simple thing I need to do but just doesn't work in VB.NET.
I have a string with HTML code and I want to load it into a HTMLDocument
object or something similiar to it so I can access the the tags and tags
value (<td> <table>, etc) by code.

But it just doesn't work in VB.NET but works in VB6. Please someone just
show me the right way to do this simple thing.

My code (which doesnt work):

Dim str0 as string = "<html> <body> Hi</body></html>
Dim doc as HTMLDocument = new HTMLDocument

doc.body.innerH TML = str0
''' This doesn't work. How can I load HTML into an HTML like
object??? Please help and thanks in advance


J.

Feb 8 '06 #2
Joe wrote:
Hi, I have a simple thing I need to do but just doesn't work in VB.NET.
I have a string with HTML code and I want to load it into a HTMLDocument
object or something similiar to it so I can access the the tags and tags
value (<td> <table>, etc) by code.

But it just doesn't work in VB.NET but works in VB6. Please someone just
show me the right way to do this simple thing.

My code (which doesnt work):

Dim str0 as string = "<html> <body> Hi</body></html>
Dim doc as HTMLDocument = new HTMLDocument

doc.body.innerH TML = str0
''' This doesn't work. How can I load HTML into an HTML like
object??? Please help and thanks in advance


J.


I'm not sure how VB.NET renders the DOM, but if it does it like it's
supposed to, I might know why your program isn't working.

Try removing the <html><body> tags from the string and pushing that into
the HTMLDocument object's body.innerHTML

With the way the DOM works, it will yell at you if you try and put
<html></html> inside of the body.innerHTML (which is in actuallity
<html><body>[here]</body></html>.

As I said, I'm not sure how VB.NET impliments the HTML DOM, so I could
be wrong, but good luck none the less!
Feb 9 '06 #3
Joe,

You can by instance have alook at the answers given by Herfried and me in
this newsgroup on your same question yesterday.

Cor
Feb 9 '06 #4

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

Similar topics

1
21284
by: BKM | last post by:
I've been using the following 2 ways to make sure my WebBrowser is finished loading a page before continuing with the next code. do:doevents:loop while WebBrowser.Busy do:doevents:loop until WebBrowser.ReadyState = STATE_COMPLETE (or something like that. I don't have the code in front of me) But, for some reason, occasionally the code...
1
8273
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two dropdown lists. If you change the selection of the left one (e.g. choose parentoption2), it should open up page2.htm in a popup window.
6
1348
by: koen colen | last post by:
Hi, simple question I guess. The question is actually in the code itself as this was the simplest way to explain. .... var favorite = GetCookie('lang'); if (favorite != null) { switch (favorite) { case 'nederlands' : url = 'ned.html'; break;
7
1759
by: J. Hall | last post by:
Hi dudes, Got a simple webpage, with three numeric text input boxes, the idea being that the user is asked to insert percentages of their business around the world... UK, Europe, Other Obviously this mustn't exceed 100% and so I OnChange I simply want to check that all three boxes have a value, and if so sum them up and alert the user
2
8379
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the...
1
1447
by: VictorT | last post by:
Hi All, I am trying to create a simple Windows form that lists a users' data one user at a time with the usual "Next" & "Previous" buttons. Upon loading the form, I am able to populate all textboxes however when clicking either of the buttons, nothing happens - the data from the next/previous rows does not re-populate the textboxes. This is...
73
4578
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an endless loop in a line with: if a==b: print 'OK' I mean, it would be of much help to me on my way to understanding Python to know how such prefix...
27
4599
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res = $doc->loadHTMLFile("./aBasicSearchResult.html"); if ( $res == true ) { $zip = $doc->getElementById('zipRaw_id')->value; if ( 0 != $zip ) {
2
1220
by: Olie | last post by:
I find the comments by Microsoft about the GAC slightly amusing stating the the GAC was created to simplify sharing of assemblies. I have found it less than simple. I have a solution with three projects ProjectA, ProjectB and ProjectC. ProjectB references ProjectC ProjectA references ProjectB and ProjectC
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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
8200
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
8215
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
6610
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
5390
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...
1
2345
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
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
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.