In //header[.//span[contains(text(), 'part_title')]]//label[contains(@class, 'start')]
, what does the .
dot in .//
mean?
Asked
Active
Viewed 2,165 times
0
-
Have you learned about XPath syntax yet? https://msdn.microsoft.com/en-us/library/ms256122(v=vs.110).aspx – 4castle Mar 13 '17 at 21:37
1 Answers
9
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.

Jim Garrison
- 85,615
- 20
- 155
- 190
-
This is correct (+1). See also [What is the difference between .// and //* in XPath?](http://stackoverflow.com/q/35606708/290085) – kjhughes Mar 13 '17 at 23:11