Link to home
Start Free TrialLog in
Avatar of dj_user2
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[Type = 'Alternative' AND Details/Release = '2008%' ]/Price "/>
<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>

Open in new window

Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

<xsl:value-of select="Catalog/Items/CD[Type = 'Alternative' AND starts-with(Details/Release, '2008') ]/Price "/>
Avatar of dj_user2
dj_user2

ASKER

I get this error message

Expected token ']' found 'NAME'. Catalog/Items/CD[Type = 'Alternative' -->AND <--starts-with(Details/Release, '2008') ]/Pr...

<?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>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial