0
我在XML是這樣的:如何檢查標籤是否包含特定的字符串?
<doc>
<people>
<adress>
<town>nameoftown</town>
</adress>
</people>
</doc>
我要檢查標籤鎮含有特定字符串。我知道我可以使用計數功能,但我想這樣做了這種方式:
XSL:
<ABC>
<xsl:variable name="counter" select="0"/>
<xsl:for-each select="/doc/people/adress/town">
<xsl:if test="contains(text(), 'nameoftown')">
<xsl:variable name="counter" select="$counter+1"/>
</xsl:if>
</xsl:for-each>
<xsl:value-of select="$counter"/>
</ABC>
所以,你需要算'包含'nameoftown'的城鎮? –
是(10個以上的字符) – keid
爲什麼你不想使用'count'函數? –