|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Simple but difficult to find solution for loading HTML into objectI 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. 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'. Show quoteHide quote "Joe" <johnty***@yahoo.com> wrote in message news:udr9rjOLGHA.344@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. > > > Joe wrote:
Show quoteHide quote > Hi, I have a simple thing I need to do but just doesn't work in VB.NET. I'm not sure how VB.NET renders the DOM, but if it does it like it's > > > 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. > > > 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! Joe,
You can by instance have alook at the answers given by Herfried and me in this newsgroup on your same question yesterday. Cor
IsNumeric Bug or misunderstanding?
Are people using data binding now? Accessing embedded resources Upgrading VB2003 to 2005 what's the difference Function parameter function sorting inherited BindingList Strange behavior data-bound combobox Help referencing a variable in HTML of an aspx page VB Project security violation on new Workstation |
|||||||||||||||||||||||