在我的DOM中,我有3个表,每个表都有几个输入字段,是否可以写xpath来表示第二个表的第三个输入 我只能找到每个表的第一个输入,因此我假设它的括号是
我确实尝试过 (// table [@ class ='table-name'])2 [3] 也 ((// table [@ class ='table-name'])[2])(// input)[3]
答案 0 :(得分:2)
“第二个表中的第三个输入”:
((//table)[2]//input)[3]
//table
。(//table)[2]
中选择第二个(//table)[2]//input
请注意,(//table)[2]
是“从所有表中的任何地方,取第二个表” ,而//table[2]
是“取作为其第二个子表的所有表各自的父母” 。前者只能选择一个表,而后者可以选择多个表。