xpathGet nodes relative to the current node


Syntax

  1. All ancestors of a node
    • /path to the node/ancestor::node()
  2. A specific ancestor of a node
    • /path to the node/ancestor::ancestor_name
  3. Parent of a node
    • /path to the node/parent::node()
  4. Following siblings of a node
    • /path to the node/following-sibling::node()
  5. A specific sibling following a node
    • /path to the node/following-sibling::sibling_name
  6. Preceding siblings of a node
    • /path to the node/preceding-sibling::node()
  7. A specific sibling preceding a node
    • /path to the node/preceding-sibling::sibling_name
  8. All immediate child nodes of a node
    • /path to the node/child::node()
  9. A specific immediate child node of a node
    • /path to the node/child::chid_name
  10. All the descendants of a node
    • /path to the node/descendant::node()
  11. All specific descendants of a node
    • /path the to node/descendant::descendant_name

Parameters

Axisselects
ancestorall the ancestor nodes
parentparent node
following-siblingsiblings following the node
preceding-siblingsiblings preceding the node
childimmediate children
descendantall the descendant irrespective of the nesting level

Remarks

These axes can be used in combination with other functions to suit our needs.