XPath基础语法(2)

< DOCTYPE html PUBLIC -WCDTD XHTML StrictEN httpwwwworgTRxhtmlDTDxhtml-strictdtd>

7. name() :

//*[name()='BBB']

     <AAA>
          <BCC>
               <BBB/>
               <BBB/>
               <BBB/>
          BCC>
          <DDB>
               <BBB/>
               <BBB/>
          DDB>
          <BEC>
               <CCC/>
               <DBD/>
          BEC>
     AAA>

//*[starts-with(name(),'B')]

     <AAA>
          <BCC>
               <BBB/>
               <BBB/>
               <BBB/>
          BCC>
          <DDB>
               <BBB/>
               <BBB/>
          DDB>
          <BEC>
               <CCC/>
               <DBD/>
          BEC>
     AAA>

//*[contains(name(),'C')]

     <AAA>
          <BCC>
               <BBB/>
               <BBB/>
               <BBB/>
          BCC>
          <DDB>
               <BBB/>
               <BBB/>
          DDB>
          <BEC>
               <CCC/>
               <DBD/>
          BEC>
     AAA>

8. string-length() :

//*[string-length(name()) = 3]

     <AAA>
          <Q/>
          <SSSS/>
          <BB/>
          <CCC/>
          <DDDDDDDD/>
          <EEEE/>
     AAA>

//*[string-length(name()) < 3]

     <AAA>
          <Q/>
          <SSSS/>
          <BB/>
          <CCC/>
          <DDDDDDDD/>
          <EEEE/>
     AAA>

//*[string-length(name()) > 3]

     <AAA>
          <Q/>
          <SSSS/>
          <BB/>
          <CCC/>
          <DDDDDDDD/>
          <EEEE/>
     AAA>

9. "|" :

//CCC | //BBB

     <AAA>
          <BBB/>
          <CCC/>
          <DDD>
               <CCC/>
          DDD>
          <EEE/>
     AAA>

/AAA/EEE | //BBB

     <AAA>
          <BBB/>
          <CCC/>
          <DDD>
               <CCC/>
          DDD>
          <EEE/>
     AAA>

/AAA/EEE | //DDD/CCC | /AAA | //BBB

     <AAA>
          <BBB/>
          <CCC/>
          <DDD>
               <CCC/>
          DDD>
          <EEE/>
     AAA>

posted @ 2006-11-09 00:27  netcorner  阅读(128)  评论(0编辑  收藏  举报