>> English << | česky | Nederlands | Français | Español | По-русски | Deutsch | 中文 | Italiano | Polski ZVON > Tutorials > XPath Tutorial
>> Example 4 << | Prev | Next

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>
Open the example in XLab. | Tree view (JPG)
 
/AAA/BBB[last()]
Select the last BBB child of element AAA

     <AAA>
          <BBB/>
          <BBB/>
          <BBB/>
          <BBB/>
     </AAA>
Open the example in XLab. | Tree view (JPG)