xpath Traversing following and preceding nodes


Example

The following-sibling and preceding-sibling axes contain the siblings before or after the context node, and the following and preceding axes contain all nodes in the document before or after the context node, but:

  • None of these axes contain attribute or namespace nodes.
  • The following axis doesn't contain any descendants.
  • The preceding axis doesn't contain any ancestors.

Examples:

following::span[1]
following-sibling::*[last()]