| short | long | means | try it! |
. |
self::node() |
me, whatever I happen to be (element, attribute, comment, processing instruction, document root, or even text) (note: long and short are not exactly equivalent) | oXygen shows node cursor is in |
said |
child::said |
my said children |
list all head elements for div children of the body |
* |
child::* |
all my element children | list all children of titleStmt |
//div |
descendant::div |
my div descendants (note: long and short are not
exactly equivalent) |
list all stage directions (stage) |
.. |
parent::node() |
my parent, whatever it happens to be (element or root) | list the parents of stage directions |
| [none] | parent::author |
my parent, if it is an author |
list the speech (sp) parents of stage directions |
| [none] | ancestor::div |
my div ancestors |
list all the headings of the div ancestors of the famous To be, or
not to be (which you can find by searching for it) |
| [none] | ancestor::* |
all my ancestors | list the ancestors of the author element |
This is a good cheat sheet for the different shorthands for writing in Xpath. We’ve already discussed the forward slash as shorthand for child, but now you can see that there are other ways of looking for different XPath axes (you don’t always want to be writing out descendant!). You can also try the queries in the far left column to try out different XPath searches.