C# 如何使用SelectNodes排除特定类?
我使用C# 如何使用SelectNodes排除特定类?,c#,xpath,html-agility-pack,C#,Xpath,Html Agility Pack,我使用HtmlAgiliyPack从站点获取tr列表。现在该表上有以下行: <tr class="group-head"> <tr/> <tr/> <tr class="group-head"> <tr/> 但这一回报: System.Xml.XPath.XPathException:“//tr[not(@class,'group head')]”中的函数“not”具有无效的参数数 如果要检查是否存在不平等使用 //tr[not(@c
HtmlAgiliyPack
从站点获取tr列表。现在该表上有以下行:
<tr class="group-head">
<tr/>
<tr/>
<tr class="group-head">
<tr/>
但这一回报:
System.Xml.XPath.XPathException:“//tr[not(@class,'group head')]”中的函数“not”具有无效的参数数
如果要检查是否存在不平等使用
//tr[not(@class='group-head')]
在整个表达式中,这是
HtmlNodeCollection rows =
doc.GetElementbyId("page_player_1_block_player_trophies_5")
.SelectNodes("//tr[not(@class='group-head')]");
或者,如果属性值中有多个字符串,请使用contains(…)
函数:
//tr[not(contains(@class,'group-head'))]
//tr[not(contains(@class,'group-head'))]