在//header[.//span[contains(text(), 'part_title')]]//label[contains(@class, 'start')]中,. .// 中的点是什么意思?
In //header[.//span[contains(text(), 'part_title')]]//label[contains(@class, 'start')], what does the . dot in .// mean?
推荐答案您需要了解 XPath上下文"节点的概念.在导航 XPath 表达式时,每个步骤都会标识一个上下文节点或节点集,从其中计算后续表达式,绝对路径除外,例如 //.
You need to learn about the concept of the XPath "context" node. When navigating an XPath expression, every step identifies a context node or node-set from which the subsequent expression is evaluated, except for absolute paths such as //.
构造 .//span 的意思是从当前节点开始,在当前上下文节点下的任何级别找到下一个后代 span.与 对比./span,表示当前上下文节点的直接子节点 span.
The construction .//span means "starting at the current node find the next descendant span at any level below the current context node. Contrast with ./span, which would mean an immediate child span of the current context node.
没有前导点 /span 表示根节点,如果它是 span,并且 //span 表示第一个 span 在任何级别的文档中.
Without the leading dot /span means the root node if it's a span, and //span means the first span in the document at any level.
或者,更简单地说,前导点与 Linux 目录中的 . 条目具有完全相同的含义.
Or, to put it more simply, the leading dot has exactly the same meaning as the . entry in a Linux directory.
更多推荐
xpath“.//span",点是什么意思?
发布评论