What are the different XPath Axes?

ali
ali

Posted On: Feb 28, 2021

 

An XPath Axes defines the node-set relative to the current (context) node. It is used to locate the node that is relative to the node on that tree.

Different XPath Axes are listed below:

S. N.Axis nameDescription
1ancestorThis contains all the elements like grandparents, parents’ ancestors of the contextnode. In simple terms, this axis contains the root of the node.
2ancestor-or-selfThis refers to all the ancestor’s nodes and the root node itself (context node).
3childIt refers to the child of the current node in the document during the traverse.
4attributeRefers to attributes of the current node in the specified document.
5descendantThis refers to the descendants of the context node in the XML document. Namespaces or attributes are not included here.
6descendant-or-selfThis refers to the descendants of the context node in the XML document and the context node itself.
7followingThis contains all the nodes after the context node in a specific order but excluding the context node's descendants.
8following-siblingIt contains the next subsequent nodes siblings followed by the root node.
9selfSpecifies their present node in the tree.
10parentIt contains only one parent of the current node.
11namespaceIt refers to the namespace node of the root node with xmlns. And the axis is empty only when the context node is an element.
12precedingIt contains all the nodes that come before the current tags(node).
13preceding-siblingThe node traversed by the current context node to a previous sibling tag.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    XPath Interview Questions

    Explain what is XPath?

    XPath stands for XML Path Language. It is defined as a query language for selecting nodes from an XML document. It is used to find values such as strings, numbers, or Boolean values from the content o...

    XPath Interview Questions

    Explain XPath Path Expressions?

    XPath Path Expressions are a combination of variables and operators. To select nodes or node-sets in an XML document XPath uses path expressions that are used in JavaScript, Java, XML Schema, PHP, Pyt...

    XPath Interview Questions

    Where XPath is used?

    XPath stands for is used to find the location of any element on a webpage or to navigate through elements and attributes in an XML document....