dj_user2
asked on
XSL select value-of query
In the below sample xml, I want to select the Price for all the CDs with type 'Alternative' and release date in 2008. How can I do that?
<xsl:value-of select="Catalog/Items/CD[T ype = 'Alternative' AND Details/Release = '2008%' ]/Price "/>
<xsl:value-of select="Catalog/Items/CD[T
<Catalog>
<Items>
<CD>
<Type>Alternative</Type>
<Details>
<Title>Coldplay's Album</Title>
<Release>2008-05-30</Release>
</Details>
<Price>12.00</Price>
</CD>
<CD>
<Type>Rock</Type>
<Details>
<Title>U2's Album</Title>
<Release>2008-07-15</Release>
</Details>
<Price>18.00</Price>
</CD>
<CD>
<Type>Alternative</Type>
<Details>
<Title>FFF's Album</Title>
<Release>2007-05-30</Release>
</Details>
<Price>20.00</Price>
</CD>
</Items>
</Catalog>
<xsl:value-of select="Catalog/Items/CD[T ype = 'Alternative' AND starts-with(Details/Releas e, '2008') ]/Price "/>
ASKER
I get this error message
Expected token ']' found 'NAME'. Catalog/Items/CD[Type = 'Alternative' -->AND <--starts-with(Details/Rel ease, '2008') ]/Pr...
Expected token ']' found 'NAME'. Catalog/Items/CD[Type = 'Alternative' -->AND <--starts-with(Details/Rel
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>
<xsl:value-of select="Catalog/Items/CD[Type = 'Alternative' AND starts-with(Details/Release, '2008') ]/Price "/>
</h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.