xml - How to iterate through multiple tags checking each tag value -


hi new bee xml/xslt. can me on below requirement have multiple tags same name

<so_servicetype>xxxx</so_servicetype> <so_servicetype>yyyy</so_servicetype> <so_servicetype>zzzz</so_servicetype> 

how iterate , check value of each tag

this solution 'iterates' on each so_servicetype node...

  <xsl:template match="/">       <xsl:apply-templates />     </xsl:template>    <xsl:template match="so_servicetype">     <xsl:if test="text()='zzzz'">       <sample>zzzz value</sample>     </xsl:if>     <node>     <xsl:value-of select="."/>     </node>   </xsl:template> 

result

<node>xxxx</node> <node>yyyy</node> <sample>zzzz value</sample> <node>zzzz</node> 

edit

if want output 'true' in result tree if text() matches a-70-00you can this:

  <xsl:template match="so_servicetype">     <xsl:if test="text()='a-70-00'">true</xsl:if>   </xsl:template> 

remember xslt way transform input output. in xslt describe rules needs applied desired output result. try think want happen input node instead of how want produce output.


Comments