hectorsales Posted April 24, 2013 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
Martin Honnen Posted April 25, 2013 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.