Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用SelectNodes排除特定类?_C#_Xpath_Html Agility Pack - Fatal编程技术网

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'))]