属性的值可以被用来作为选择的准则, normalize-space函数删除了前部和尾部的空格, 并且把连续的空格串替换为一个单一的空格
 
//BBB[@id='b1']
选择含有属性id且其值为'b1'的BBB元素

     <AAA>
          <BBB id = "b1"/>
          <BBB name = " bbb "/>
          <BBB name = "bbb"/>
     </AAA>
 
//BBB[@name='bbb']
选择含有属性name且其值为'bbb'的BBB元素

     <AAA>
          <BBB id = "b1"/>
          <BBB name = " bbb "/>
          <BBB name = "bbb"/>
     </AAA>
 
//BBB[normalize-space(@name)='bbb']
选择含有属性name且其值(在用normalize-space函数去掉前后空格后)为'bbb'的BBB元素

     <AAA>
          <BBB id = "b1"/>
          <BBB name = " bbb "/>
          <BBB name = "bbb"/>
     </AAA>

posted on 2006-06-24 11:02  滋心  阅读(472)  评论(0编辑  收藏  举报