The descendant Axis

The descendant axis searches through all the descendants of the context node, not just the immediate children. For example, /descendant::BORN[position()=3] selects the third BORN element encountered in a depth-first search of the document tree. (Depth first is the order you get if you simply read through the XML document from top to bottom.) In Listing 17-1, that selects Louise Pauline Bellau's birthday, <BORN>29 Oct 1868</BORN>.

The descendant axis can be abbreviated by using a double slash in place of a single slash. For example, //BORN[position()=3] also selects the third BORN element encountered in a depth-first search of the document tree. //NAME selects all NAME elements in the document. //PERSON/NAME selects all NAME children of PERSON elements.


Previous | Next | Top | Cafe con Leche

Copyright 1999, 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified February 1, 2000