Question

Here's the code from the XML I'm trying to pull:

<ticket_price type="adult" status="available">25.00</ticket_price>
<ticket_price type="child" status="none">11.00</ticket_price>
<ticket_price type="junior" status="available">0.00</ticket_price>

and this is the xslt I'm working with:

    <xsl:for-each select="ticket_price">
            <xsl:element name="tickets">
                <xsl:value-of select="ticket_price"/>
                <xsl:element name="br"/>
                <xsl:value-of select="@type"/>
                <xsl:element name="br"/>
                <xsl:value-of select="@status"/>
            </xsl:element>
        </xsl:for-each>

The problem I'm having is that when I run the XSL transformer, only the type and status are being shown, not the price of the tickets. Eg:

<tickets><br>adult<br>available</tickets>
<tickets><br>child<br>none</tickets>
<tickets><br>junior<br>available</tickets>

Any advice on how I should be doing this?

Was it helpful?

Solution

Instead of <xsl:value-of select="ticket_price"/> do <xsl:value-of select="."/> because you are already at the ticket_price node.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top