【发布时间】:2013-12-03 12:06:58
【问题描述】:
我正在使用 HtmlAgilityPack 来解析一些 html,并且我正在尝试提取图像标签的样式属性。下面是一些示例代码:
Dim hd As New HtmlDocument()
hd.LoadHtml("<img style='float:left;' />")
Dim s As String = hd.DocumentNode.GetAttributeValue("style", String.Empty)
问题是字符串s总是空的,当我在调试中检查hd.DocumentNode时发现属性集合也是空的并且HasAttributes设置为false。
这可能与我使用 html 片段而不是完整文档填充 html 文档对象的方式有关吗?
欢迎提出任何建议。
【问题讨论】:
标签: .net vb.net html-agility-pack