Attributes and count() in xpath expression

后端 未结 3 794
鱼传尺愫
鱼传尺愫 2021-01-26 21:48

Given the following XML file :


    
        3
        
    
    

        
3条回答
  •  迷失自我
    2021-01-26 22:24

    /*/*/*
    

    This selects all "grand-children of the top element -- these are: c, d, c, d

    /*//*
    

    This selects all descendant elements of the top element: b, c, d, b, c, d, e, f

    /*/*//@*
    

    This selects all attributes either of children of the top element or of their descendants: n, o, p, n, o, p, q, r, s.

    Therefore, the counts produced must be, respectively:

    4, 8, 9
    

    XSLT - based verification:

    
     
    
     
       
    =========
       
    =========
       
     
    
    

    When this transformation is performed on the provided XML document (never, never ever present the document with a picture!!!):

    
     
       3
       
     
     
       3
       
         2
       
     
     
    
    

    The Xpath expressions are evaluated and their results are copied to the output:

       4
    =========
       8
    =========
       9
    

提交回复
热议问题