Expresion in square brackets can further specify an element. A number in the brackets gives the position of the element in the selected set. The function last() selects the last element in the selection.
/AAA/BBB[1]
Select the first BBB child of element AAA
<AAA>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>
/AAA/BBB[last()]
Select the last BBB child of element AAA
<AAA>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>