views:

179

answers:

1

I use this to load html page by xml

Dim xmlDoc As New XmlDocument()
xmlDoc.Load(Server.MapPath("index.htm"))

Or

Dim xmldoc As XDocument
xmldoc = XDocument.Load(Server.MapPath("index.htm"))

but i got some errors like :

  • Expecting an internal subset or the end of the DOCTYPE declaration. Line 2, position 14.
  • '>' is an unexpected token. The expected token is '"' or '''. Line 1, position 62.
  • Expecting an internal subset or the end of the DOCTYPE declaration. Line 5, position 20.

all these errors came to me when i solve one another one show up.

i'm asking do i use the perfect way to load this file or is there another way for that?

thanks for who will try to help me.

+1  A: 

Use the HTML Agility Pack to parse HTML documents.

This is a .NET library that parses HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to System.Xml.XmlDocument, but for HTML documents. It supports XPath and XSLT.

Dim htmlDoc As New HtmlDocument()
htmlDoc.Load(Server.MapPath("index.htm"))
Lachlan Roche