Advanced XPATH syntax
Monday, March 29, 2010
2:20 PM
Advanced XPATH syntax
conditions: select locations that satisfy tests.
foo/bar[@title='cat'] matches a tag <bar> inside a tag <foo>, that happens to have an attribute 'title'whose value is 'cat'
bar[@title and @publisher] matches a tag <bar> that has both 'title' and 'publisher' attributes.
Examples:
candy[name='chocolate']
candy[name]
candy[2]
axes: qualify how to interpret a name.
default is child: interpret names as children of current node.
self:: - current node.
parent:: - parent of current node.
preceeding-sibling:: - siblings before current node.
following-sibling:: - siblings after current node.
descendant-or-self:: - current node or descendants.
Examples:
name[.='chocolate']/following-sibling::*
candy[name='chocolate']/following-sibling::candy
Pasted from <[link]> 