hectorsales Posted April 24, 2013 Share Posted April 24, 2013 Hello I am new to the forum, I'm doing a series of exercises xml transformation and I wonder if someone can explain the difference between using, eg: XPath expression: . / task or .. / task . / / task or .. / /task Thanks and regards Link to comment Share on other sites More sharing options...
Martin Honnen Posted April 25, 2013 Share Posted April 25, 2013 Try any XPath tutorial."." denotes the context node, ".." the parent node.So"./task" selects the "task" child elements of the context node while "../task" selects the "task" child elements of the parent node of the context node.Usually you would simply use "task"instead of "./task"As for ".//task", it is short for "./descendant-or-self::node()/task", see http://www.w3.org/TR/xpath/#path-abbrev for details which says// is short for /descendant-or-self::node()/. For example, //para is short for /descendant-or-self::node()/child::para and so will select any para element in the document (even a para element that is a document element will be selected by //para since the document element node is a child of the root node); div//para is short for div/descendant-or-self::node()/child::para and so will select all para descendants of div children. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now