If the expression //* is equivelant to the following expression /descendant-or-self::* and it returns all the elements in the xml document.
So why exists difference between
/a//*(that does not returnsaelement)
and
/a/descendant-or-self::*(which returns alsoaelement)
Why /a//* does not returns also a element itself?
CodePudding user response:
// is actually short for /descendant-or-self::node()/ (note the trailing slash!), hence //* is actually short for /descendant-or-self::node()/* See https://www.w3.org/TR/1999/REC-xpath-19991116/#path-abbrev
So, from your example, /a//* actually means /a/descendant-or-self::node()/*, which is equivalent to /a/descendant::*, and is not the same as /a/descendant-or-self::*
