Quick response; yes, .. / and parent :: * are equivalent, but you get different results because your XPath expressions are different.
Longer answer;
The expressions parent :: node () and .. are equivalent, the latter is an abbreviated form of the former according to the W3C XPath Recommendation .
You will get similar behavior from parent :: *, because XML forms a tree, so any child can have at most one parent.
The reason you get different results is because of different requests. The first has an extra * at the end (../../*), which probably returns a sequence of children of your Node.
The second gets exactly the parent element of the parent of the context node (in abbreviated form .. / ..), which is your node element of interest.
Example:
For a document
<?xml version="1.0" encoding="UTF-8"?> <root> <Node> <id type="image"> <id attr1="myVal"> </id> </id> </Node> </root>
Inquiries
//Node/id[@type='image']/id[@attr1='myVal']/../../*
and
//Node/id[@type='image']/id[@attr1='myVal']/parent::*/parent::*/*
return node id [@type = 'image']
While requests
//Node/id[@type='image']/id[@attr1='myVal']/../..
and
//Node/id[@type='image']/id[@attr1='myVal']/parent::*/parent::*
return node Node.
source share