Pee*_*Haa 4 vb.net html-parsing html-agility-pack
我正在使用 HtmlAgilityPack 来解析 HTML。
我想检查一个元素是否具有特定的属性。
我想检查一个<a>标签是否具有该href属性。
Dim doc As HtmlDocument = New HtmlDocument()
doc.Load(New StringReader(content))
Dim root As HtmlNode = doc.DocumentNode
Dim anchorTags As New List(Of String)
For Each link As HtmlNode In root.SelectNodes("//a")
If link.HasAttributes("href") Then doSomething() 'this doesn't work because hasAttributes only checks whether an element has attributes or not
Next
Run Code Online (Sandbox Code Playgroud)