Transform non well-formed document?

row118

Member
Joined
Feb 4, 2006
Messages
21
Programming Experience
5-10
My vendor doesn't always send me well-formed html documents. How can I use VB.NET to transform these documents.

VB.NET:
  xmldoc.Load(server.MapPath("SCCPage.htm"))
  dim sXpath as String 
  sXPath = "//table[id='ProductDataList']" 
		
  dim nodes as  XmlNodeList
  nodes = xmldoc.SelectNodes(sXpath)
  Literal1.Text = nodes.Item(0).InnerXml.ToString

Example of an error:

This is an unexpected token. The expected token is 'WHITESPACE'

Any way around this?
 
If the document doesn't work as Xml (which you would be lucky with a html document) you can have them fixed by the publisher, fix them yourself, or find another way to do it. For example load it into a WebBrowser control and use the DOM document to get to data, or otherwise parse the html document.
 
I just noticed you use "MapPath" so this is ASP.Net section query, also I don't think the WebBrowser control option will work in that environment. Anyway I move this thread to ASP.Net section now.
 
Back
Top