xpath find if node exists

后端 未结 6 1464
我在风中等你
我在风中等你 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:23

    Patrick is correct, both in the use of the xsl:if, and in the syntax for checking for the existence of a node. However, as Patrick's response implies, there is no xsl equivalent to if-then-else, so if you are looking for something more like an if-then-else, you're normally better off using xsl:choose and xsl:otherwise. So, Patrick's example syntax will work, but this is an alternative:

    
     body node exists
     body node missing
    
    

提交回复
热议问题