Skip to main content

XPath Axis Family Tree Analogy

The major XPath axes follow family tree terminology:

  • self:: is you.

Downward:

  • child:: are your immediate children.
  • descendant:: are your children, and their children, recursively.
  • descendant-or-self:: (aka //): are you and your descendants.

Upward:

  • parent:: is your mother or father.1
  • ancestor:: are your parent, and your parent's parent, recursively.
  • ancestor-or-self:: are you and your ancestors.

Sideways (consider elements earlier in the document to be younger):

  • previous-sibling:: are your younger siblings, in age order.
  • following-sibling:: are your older siblings, in age order.
  • previous:: are your younger siblings and their descendants, in age order.
  • following:: are your older siblings and their descendants, in age order.