I have this xml
<game>
<genre>
<action>...</action>
<racing>...</racing>
<pri开发者_运维问答ce>
..
..
</price>
</genre>
</game>
I want to check whether price node is present in the xml using xsl. how can I do that? if price node is present then call a particular template else call another template
You could simply call xsl:apply-templates with the match attribute set to the element name. If the element exists the template is called. It it does not exist, the template won't be called.
If you are trying to build a if-else statement you could check the existence like this
<xsl:choose>
<xsl:when test="boolean(price)">
<!-- do something -->
</xsl:when>
<xsl:otherwise>
<!-- do something else -->
</xsl:otherwise>
</xsl:choose>
So you can check for existence of an element and react accordingly.
加载中,请稍侯......
精彩评论