XPath中.//和//*有什么区别? [英] What is the difference between .// and //* in XPath?
问题描述
通过Firebug查找相对的XPath时,它的创建方式类似于
While finding the relative XPath via Firebug : it creates like
-
.//*[@id='Passwd']
---------如果我们在开始时不使用点表示什么呢?
.//*[@id='Passwd']
--------- what if we dont use dot at the start what it signifies?
只需在Xpath中添加//*
-
它突出显示---各种页面元素----------它表示什么?
Just add //*
in the Xpath --
it highlights --- various page elements ---------- what does it signify?
以下是XPaths for Gmail密码字段. *
的意义是什么?
Below are XPaths for Gmail password fields. What is significance of *
?
-
.//*[@id='Passwd']
//child::input[@type='password']
推荐答案
这些表达式都选择了不同的节点集:
These expressions all select different nodesets:
.//* [@ id ='Passwd']
.//*[@id='Passwd']
." 开始"表示当前处理从当前节点开始. "*"选择从该当前节点下降的所有元素节点,其@id
-attribute-value等于"Passwd".
The '.' at the beginning means, that the current processing starts at the current node. The '*' selects all element nodes descending from this current node with the @id
-attribute-value equal to 'Passwd'.
如果我们一开始不使用点表示什么呢?
What if we don't use dot at the start what it signifies?
然后,在整个文档中选择所有@id
-attribute-value等于'Passwd'的元素节点.
Then you'd select all element nodes with an @id
-attribute-value equal to 'Passwd' in the whole document.
只需在XPath中添加//*-突出显示---各种页面元素
Just add //* in the XPath -- it highlights --- various page elements
这将选择整个文档中的所有元素节点.
This would select all element nodes in the whole document.
以下提到:XPatht的"Gmail密码"字段是真实的*的含义是什么?
Below mentioned : XPatht's for Gmail Password field are true what is significance of * ?
.//*[@id='Passwd']
这将选择从@id
-attribute-value等于'Passwd'的当前节点下降的所有元素节点.
This would select all element nodes descending from the current node which @id
-attribute-value is equal to 'Passwd'.
//child :: input [@ type ='password']
//child::input[@type='password']
这将选择所有名为input
的子元素节点,这些子元素节点的@type
属性值等于'password'.可以省略child::
轴前缀,因为它是默认行为.
This would select all child-element nodes named input
which @type
-attribute-values are equal to 'password'. The child::
axis prefix may be omitted, because it is the default behaviour.
此处w3school.com 进行了解释.
此处在另一个w3school.com页面上说明了轴(处理中的当前点).
这篇关于XPath中.//和//*有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!