What is the difference (if exists) between the following expressions ?
/descendant-or-self::node()
descendant-or-self::node()
I don't understand what is the meaning of the /
in this case in the beginning of the first expression.
According to the explanation from the class, the meaning of /
is go down a level in the tree.
So how is this reflected here?
(According to checks that I did, it's seen that a difference does not exist, but I don't understand why according to the explain mentioned above given by my lecturer.)
CodePudding user response:
The difference is that of absolute vs relative selection.
An XPath starting with
/
is absolute (based on the root node of the document).An XPath starting with an axis, or
./
, is relative to the context node.