Skip to main content

XQuery index-of Function

XQuery index-of Function

The index-of function is used to track items in the given sequence. It returns integers to indicate the availability of items in a given sequence.

Syntax

index-of($seq as anyAtomicType()*, $target as anyAtomicType())

Input Parameters

  • $seq is the provided sequence. A sequence can contain 0 or more items.
  • $target is the item whose index is to be returned.

Example

XQuery Expression
let $items := (1,2,3,4,5,6)
let $indexOf := index-of($items,4)
return
<result>
<indexof>{$indexOf}</indexof>
</result>

Output
<result>   
return <indexof>4</indexof>
</result>