473,383 Members | 1,877 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,383 software developers and data experts.

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.innerHTML = 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 3777
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*******@yahoo.com> wrote in message
news:ud*************@TK2MSFTNGP11.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.innerHTML = 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.innerHTML = 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
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...
1
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...
6
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...
7
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 ...
2
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...
1
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...
73
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...
27
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 =...
2
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...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.