我在查找将返回没有UL
属性的ID
列表的语法时遇到麻烦。
以下内容将一无所获
For Each ul As HtmlAgilityPack.HtmlNode In doc.DocumentNode.SelectNodes("//ul[@id='']")
我知道可以使用If语句将所有
UL
然后返回到单独的字段,但是HtmlAgilityPack是否可以返回没有UL
属性的ID
列表?
最佳答案
//ul[not(@id)]
可以解决问题。
演示(使用xmllint
):
$ xmllint index.html --xpath '//ul[not(@id)]/text()'
1
3
其中
index.html
包含:<div>
<ul>1</ul>
<ul id="test">2</ul>
<ul>3</ul>
</div>
关于vb.net - 查找没有属性的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23525795/