Home >Online Product Documentation >Table of Contents >Determining the Position Number of a Node
Determining the Position Number of a Node
The position()
function returns an integer that indicates the position of the node within the parent. Positions start with 1
; a node with a position of 1
is always the first node in the collection.
For example, the following query returns the first three degree
elements in the document:
The next query finds the first two book children in the current context:
The XPath processor executes the position()
function with respect to the parent node. Consider the following data:
The following expression returns the first y
element contained in each x
element:
For more information, see also Finding an Element with a Particular ID.