[英]Difference between //, .//, and ..// in XPath?
Can anyone please help with the difference between the below XPaths and help me understand which of these to use when.任何人都可以帮助解决以下 XPath 之间的区别,并帮助我了解何时使用其中的哪些。 I have found all three of them to work but not sure when to use them.
我发现它们三个都可以工作,但不确定何时使用它们。
Get Element Text ${output} //priority
Get Element Text ${output} .//vrrp-group/name
Get Element Text ${output} ..//track/priority-hold-time
//
selects among descendant or self nodes (along the descendant-or-self
axis ). //
在后代节点或自身节点之间进行选择(沿descendant-or-self
节点descendant-or-self
轴)。 It is short for /descendant-or-self::node()/
.它是
/descendant-or-self::node()/
缩写。
//
starts from the root node, thus covering the entire document. //
从根节点开始,从而覆盖整个文档。.//
starts from the context node . .//
从上下文节点开始。..//
starts from the parent of the context node. ..//
从上下文节点的父节点开始。//priority
selects all priority
elements in the document. //priority
选择文档中的所有priority
元素。.//vrrp-group/name
selects, beneath the context node, all name
elements with a vrrp-group
parent. .//vrrp-group/name
在上下文节点下选择所有具有vrrp-group
父级的name
元素。..//track/priority-hold-time
selects, beneath the parent of the context node, all priority-hold-time
elements with a track
parent. ..//track/priority-hold-time
在上下文节点的父节点下选择所有具有track
父节点的priority-hold-time
元素。 Robotframework note: Robotframework注意事项:
In the context of the Get Element Text
Robotframework XML library command, the XPath must be relative to the source node ( ${output}
in your case).在
Get Element Text
Robotframework XML 库命令的上下文中,XPath 必须相对于源节点(在您的情况下${output}
)。 Absolute XPaths such as //priority
are not allowed there.那里不允许使用绝对 XPath,例如
//priority
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.