XML:
<laptop category="business">
<name lang="en">HP Pavilion 15</name>
<color>Silver</color>
<processor>i5-1135G7</processor>
<price type ="pln">3200</price>
<price type ="usd">795</price>
<price type ="euro">700</price>
</laptop>
XSL:
<h2><xsl:value-of select="name"/></h2>
<p>Color: <xsl:value-of select="color"/></p>
<p>Processor: <xsl:value-of select="processor"/></p>
I want to show as above, 3 different prices in XSL based on attribute type, how can i do it? Please help.
>Solution :
The question is not entirely clear.
To show a specific price, you could use a predicate – for example (from the context of laptop), the instruction:
<xsl:value-of select="price[@type='pln']"/>
will return 3200.
To show all prices, you could something like:
<xsl:for-each select="price">
<p>
<xsl:text>Price: </xsl:text>
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
<xsl:value-of select="@type"/>
</p>
</xsl:for-each>
to get:
