English | česky | Nederlands | Français | Español | >> По-русски << | Deutsch | 中文 | Italiano | Polski ZVON > Tutorials > XPath Tutorial
>> Пример 21 << | Назад | Вперед

Оси ancestor, descendant, following, preceding и self axes покрывают документ (за исключением узлов атрибутов и пространств имен): они не перескаются и вместе содержат все узлы документа.
 
//GGG/ancestor::*

     <AAA>
          <BBB>
               <CCC/>
               <ZZZ/>
          </BBB>
          <XXX>
               <DDD>
                    <EEE/>
                    <FFF>
                         <HHH/>
                         <GGG>
                              <JJJ>
                                   <QQQ/>
                              </JJJ>
                              <JJJ/>
                         </GGG>
                         <HHH/>
                    </FFF>
               </DDD>
          </XXX>
          <CCC>
               <DDD/>
          </CCC>
     </AAA>
Открыть пример в XLab | Как дерево (JPG)
 
//GGG/descendant::*

     <AAA>
          <BBB>
               <CCC/>
               <ZZZ/>
          </BBB>
          <XXX>
               <DDD>
                    <EEE/>
                    <FFF>
                         <HHH/>
                         <GGG>
                              <JJJ>
                                   <QQQ/>
                              </JJJ>
                              <JJJ/>
                         </GGG>
                         <HHH/>
                    </FFF>
               </DDD>
          </XXX>
          <CCC>
               <DDD/>
          </CCC>
     </AAA>
Открыть пример в XLab | Как дерево (JPG)
 
//GGG/following::*

     <AAA>
          <BBB>
               <CCC/>
               <ZZZ/>
          </BBB>
          <XXX>
               <DDD>
                    <EEE/>
                    <FFF>
                         <HHH/>
                         <GGG>
                              <JJJ>
                                   <QQQ/>
                              </JJJ>
                              <JJJ/>
                         </GGG>
                         <HHH/>
                    </FFF>
               </DDD>
          </XXX>
          <CCC>
               <DDD/>
          </CCC>
     </AAA>
Открыть пример в XLab | Как дерево (JPG)
 
//GGG/preceding::*

     <AAA>
          <BBB>
               <CCC/>
               <ZZZ/>
          </BBB>
          <XXX>
               <DDD>
                    <EEE/>
                    <FFF>
                         <HHH/>
                         <GGG>
                              <JJJ>
                                   <QQQ/>
                              </JJJ>
                              <JJJ/>
                         </GGG>
                         <HHH/>
                    </FFF>
               </DDD>
          </XXX>
          <CCC>
               <DDD/>
          </CCC>
     </AAA>
Открыть пример в XLab | Как дерево (JPG)
 
//GGG/self::*

     <AAA>
          <BBB>
               <CCC/>
               <ZZZ/>
          </BBB>
          <XXX>
               <DDD>
                    <EEE/>
                    <FFF>
                         <HHH/>
                         <GGG>
                              <JJJ>
                                   <QQQ/>
                              </JJJ>
                              <JJJ/>
                         </GGG>
                         <HHH/>
                    </FFF>
               </DDD>
          </XXX>
          <CCC>
               <DDD/>
          </CCC>
     </AAA>
Открыть пример в XLab | Как дерево (JPG)
 
//GGG/ancestor::* | //GGG/descendant::* | //GGG/following::* | //GGG/preceding::* | //GGG/self::*

     <AAA>
          <BBB>
               <CCC/>
               <ZZZ/>
          </BBB>
          <XXX>
               <DDD>
                    <EEE/>
                    <FFF>
                         <HHH/>
                         <GGG>
                              <JJJ>
                                   <QQQ/>
                              </JJJ>
                              <JJJ/>
                         </GGG>
                         <HHH/>
                    </FFF>
               </DDD>
          </XXX>
          <CCC>
               <DDD/>
          </CCC>
     </AAA>
Открыть пример в XLab | Как дерево (JPG)