11.3 Branch Selection

Path segment: node-test[index/predicate]

Refine the set of nodes selected.

i

the ith node satisfying the node-test; index starts at 1

boolean

non-empty selection in the specified path originating at the context node

<article title="red"  
         canvas="yellow">  
  <section>  
    <title>First  
       section</title>  
    <sentence>Some  
       text.</sentence>  
    <sentence>More  
       text.</sentence>  
  </section>  
  <ns:appendix xmlns:ns="none"/>  
</article>

//sentence[2]

the 3rd element child of ‘section’



//*[../ns:appendix]

the ‘section’ and ‘ns:appendix’ element node



//*[../../*/*/*]

the ‘section’ and ‘ns:appendix’ element nodes



//*[../*[4]]

empty selection of nodes



//*[2]/..

the ‘sentence’ node-it has more than one children elements



//@*[../@title]

the ‘title’ and ‘canvas’ attribute nodes of ‘article’