Axes

  • Use 'child' to address the direct children of the context node.

    /child::bookstore/child::book
    /bookstore/book

    Returns all elements with the name 'book' that have as root an element with the name 'bookstore'.

  • Use 'descendant' to address the direct children or the children of children of the context node.

    /descendant::book

    Returns all elements with the name 'book' in the document.

  • Use 'parent' to address the parent node of the context node.

    parent::node()
    ..

    Returns the parent node, the name does not matter.

  • Use 'ancestor' to address the direct ancestors or the ancestors of ancestors of the context node.

    ancestor::book

    Returns all elements with the name 'book' that are ancestors of the context node.

  • Use 'following-sibling' to address the following sibling of the context node.

    following-sibling::book

    Returns the element with the name 'book' that is the next sibling.

  • Use 'preceding-sibling' to address the preceding sibling of the context node.

    preceding-sibling::book

    Returns the element with the name 'book' that is the preceding sibling.

  • Use 'following' to address all nodes in the document (document-order) after the context node.

    following::book

    Returns all elements with the name 'book' found after the context node.

  • Use 'preceding' to address all nodes in the document (document-order) before the context node.

    preceding::book

    Returns all elements with the name 'book' found before the context node.

  • Use 'attribute' to address all attributes in the context node.

    /child::bookstore/child::book/attribute::isbn
    /bookstore/book/@isbn

    Returns all isbn attributes specified on book elements with a root element of 'bookstore'.

  • Use 'namespace' to address all namespaces in the context node.

    namespace::book

    Returns the namespaces for all book elements.

  • Use 'self' to address the context node.

    self::book

    Returns the context node if the context node has a name of book.

  • Use 'self' to address the context node.

    self::book
    .book

    Returns the context node if the context node has a name of book.

  • Use 'descendant-or-self' to address the context node and all it's decendants.

    descendant-or-self::book
    //book

    Returns the context node and all descendant nodes with a name of book.

  • Use 'ancestor-or-self' to address the context node and all it's ancestors.

    ancestor-or-self::book

    Returns the context node and all ancestor nodes with a name of book.