Example 6     Previous      Next    

Values of attributes can be used as selection criteria. Function normalize-space removes leading and starting spaces and replaces sequences of whitespace characters by a single space.
 
//BBB[@id='b1']
Select BBB elements which have attribute id with value b1

     <AAA>
          <BBB id = "b1"/>
          <BBB name = " bbb "/>
          <BBB name = "bbb"/>
     </AAA>
Open the example in XLab. | Tree view (PNG)
 
//BBB[@name='bbb']
Select BBB elements which have attribute name with value 'bbb'

     <AAA>
          <BBB id = "b1"/>
          <BBB name = " bbb "/>
          <BBB name = "bbb"/>
     </AAA>
Open the example in XLab. | Tree view (PNG)
 
//BBB[normalize-space(@name)='bbb']
Select BBB elements which have attribute name with value bbb, leading and trailing spaces are removed before comparison

     <AAA>
          <BBB id = "b1"/>
          <BBB name = " bbb "/>
          <BBB name = "bbb"/>
     </AAA>
Open the example in XLab. | Tree view (PNG)



_____________________________________________
Reference Search | Sitemap | XML Glossary       ZVON | IDOOX