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
如何使用XPath选择具有4个子元素以上的tr元素?_Xpath - Fatal编程技术网

如何使用XPath选择具有4个子元素以上的tr元素?

如何使用XPath选择具有4个子元素以上的tr元素?,xpath,Xpath,XPath表达式root.XPath('//table//tr')可以获取root中的所有tr元素。 现在我想选择所有超过4个孩子的tr。如何写表达式 我尝试了//table/tr[count(child:)>4],但失败了。您就快到了,试试这个: //table/tr[count(child::*)>4] 或者简单地说: //table/tr[count(*)>4]

XPath表达式
root.XPath('//table//tr')
可以获取root中的所有
tr
元素。 现在我想选择所有超过4个孩子的
tr
。如何写表达式


我尝试了
//table/tr[count(child:)>4]
,但失败了。

您就快到了,试试这个:

//table/tr[count(child::*)>4]
或者简单地说:

//table/tr[count(*)>4]