Beginner XSL problem
-
Welcome I have XML file:
<doc> <field> <name> myName</name> <value> some value</value> </field> <field> <name> otherName</name> <value> other value</value> </field> </doc>
I have created XSL file:<xsl:template match="/"> <!-- transform fields --> <xsl:for-each select="field"> <xsl:choose> <!-- i want get data from myName field --> <xsl:when test="cd[name='myName']"> <xsl:value-of select="value"/> <xsl:when> <xsl:choose> </xsl:for-each> </xsl:template>
unfortunately it doesn't create output file as: some value What is wrong? -
Welcome I have XML file:
<doc> <field> <name> myName</name> <value> some value</value> </field> <field> <name> otherName</name> <value> other value</value> </field> </doc>
I have created XSL file:<xsl:template match="/"> <!-- transform fields --> <xsl:for-each select="field"> <xsl:choose> <!-- i want get data from myName field --> <xsl:when test="cd[name='myName']"> <xsl:value-of select="value"/> <xsl:when> <xsl:choose> </xsl:for-each> </xsl:template>
unfortunately it doesn't create output file as: some value What is wrong?Change the
select
attribute of the xsl:for-each element to either "doc/field" or "//field". <field> is not the root element; it's a child element. Change thetest
attribute of the xsl:when element to contain the value "name=' myName'". -
Change the
select
attribute of the xsl:for-each element to either "doc/field" or "//field". <field> is not the root element; it's a child element. Change thetest
attribute of the xsl:when element to contain the value "name=' myName'".