English | česky | Nederlands | Français | Español | По-русски | Deutsch | >> 中文 << | Italiano | Polski ZVON > Tutorials > XPath Tutorial
>> 实例 7 << | 前页 | 后页

count()函数可以计数所选元素的个数
 
//*[count(BBB)=2]
选择含有2个BBB子元素的元素

     <AAA>
          <CCC>
               <BBB/>
               <BBB/>
               <BBB/>
          </CCC>
          <DDD>
               <BBB/>
               <BBB/>
          </DDD>
          <EEE>
               <CCC/>
               <DDD/>
          </EEE>
     </AAA>
在XLab中打开实例 | 树视图 (JPG)
 
//*[count(*)=2]
选择含有2个子元素的元素

     <AAA>
          <CCC>
               <BBB/>
               <BBB/>
               <BBB/>
          </CCC>
          <DDD>
               <BBB/>
               <BBB/>
          </DDD>
          <EEE>
               <CCC/>
               <DDD/>
          </EEE>
     </AAA>
在XLab中打开实例 | 树视图 (JPG)
 
//*[count(*)=3]
选择含有3个子元素的元素

     <AAA>
          <CCC>
               <BBB/>
               <BBB/>
               <BBB/>
          </CCC>
          <DDD>
               <BBB/>
               <BBB/>
          </DDD>
          <EEE>
               <CCC/>
               <DDD/>
          </EEE>
     </AAA>
在XLab中打开实例 | 树视图 (JPG)