Amr*_*har 0 .net xml vb.net html-parsing
我使用它来通过XML加载HTML页面
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(Server.MapPath("index.htm"))
Run Code Online (Sandbox Code Playgroud)
要么
Dim xmldoc As XDocument
xmldoc = XDocument.Load(Server.MapPath("index.htm"))
Run Code Online (Sandbox Code Playgroud)
但是我遇到了一些错误:
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.当我解决一个,另一个出现时,所有这些错误都出现在我身上.
我问,我是否使用完美的方式来加载这个文件,还是有另一种方法呢?
使用HTML Agility Pack解析HTML文档.
这是一个解析HTML文件的.NET库.解析器非常容忍"真实世界"格式错误的HTML.对象模型与System.Xml.XmlDocument非常相似,但对于HTML文档.它支持XPath和XSLT.
Dim htmlDoc As New HtmlDocument()
htmlDoc.Load(Server.MapPath("index.htm"))
Run Code Online (Sandbox Code Playgroud)