in below xml code, need "b1" , "b2" output using xslt.
<xml> <a> <b> <b1>b1value</b1> <b2>b2value</b2> </b> <b> <b1>b1value2</b1> <b2> 2value2</b2> </b> </a> </xml>
i wrote following xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <html> <body> <xsl:for-each select="xml/a/b/*[b1='b1value']"> <xsl:value-of select="local-name()"/> <br> </br> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>
but doesn't give me output.. why?
instead if write
<xsl:for-each select="xml/a/b/*"> <xsl:value-of select="local-name()"/>
the output is:
b1 b2 b1 b2
the output need is:
b1 b2
it's not clear you're trying output.
however reason you're not getting output xslt in for-each
, xpath looking children of <b>
have child <b>
contains "b1value".
you need move predicate:
<xsl:template match="/"> <html> <body> <xsl:for-each select="xml/a/b[b1='b1value']/*"> <xsl:value-of select="local-name()"/> <br> </br> </xsl:for-each> </body> </html> </xsl:template>
Comments
Post a Comment