【发布时间】:2012-08-09 18:52:45
【问题描述】:
我试图解析的一段 HTML 包含一些不带引号的属性值,例如宽度和高度属性:
<img src="/static/logo.png" width=75 height=90 />
在 C# 代码中,阅读器会一直读取到下一个锚标记。
while (reader.ReadToFollowing("a"))
此语句报告 XmlException:
'75' is an unexpected token. The expected token is '"' or '''. Line 16, position 37.
是否有一些 XmlReaderSetting 可以使 XmlReader 更宽松?我无法控制生成的 HTML。
【问题讨论】:
-
您不应该使用 XmlReader 来解析 HTML,例如,请参阅 [Is there an XmlReader equivalent for HTML in .Net?][1]。 [1]:stackoverflow.com/questions/6452433/…
标签: c# xml-parsing html-parsing