xpath find if node exists

后端 未结 6 1431
我在风中等你
我在风中等你 2020-11-28 04:09

Using a xpath query how do you find if a node (tag) exists at all?

For example if I needed to make sure a website page has the correct basic structure like /html/bod

6条回答
  •  再見小時候
    2020-11-28 04:35

    Might be better to use a choice, don't have to type (or possibly mistype) your expressions more than once, and allows you to follow additional different behaviors.

    I very often use count(/html/body) = 0, as the specific number of nodes is more interesting than the set. For example... when there is unexpectedly more than 1 node that matches your expression.

    
        
             
        
        
        
             
        
    
    

提交回复
热议问题