By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,163 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,163 IT Pros & Developers. It's quick & easy.

Simple but difficult to find solution for loading HTML into object

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.