Skip to content Skip to sidebar Skip to footer

Xpath ".//span", What Does The Dot Mean?

In //header[.//span[contains(text(), 'part_title')]]//label[contains(@class, 'start')], what does the . dot in .// mean?

Solution 1:

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 //.

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.

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.

Or, to put it more simply, the leading dot has exactly the same meaning as the . entry in a Linux directory.


Post a Comment for "Xpath ".//span", What Does The Dot Mean?"