Reputation: 1
I have an XML, with a XSLT I try to extract values. It works, but the expression value-of select in the XSL returns only the first value "Al Pacino". How can I use it to have all the <Cast>
values?
<Questionario>
<Video ID="1" Titolo="Scarface">
<Cast>Al Pacino</Cast>
<Cast>Steven Bauer</Cast>
<Cast>Michelle Pfieffer</Cast>
<Genere>azione e avventura</Genere>
<Sottogenere>crime action</Sottogenere>
<Sottogenere>Thriller</Sottogenere>
<Sottogenere>Gangster</Sottogenere>
XSL
<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>Report Questionari Slow TV</title>
</head>
<body>
<h3>Video Visionati</h3>
<div>
<xsl:apply-templates select="//Video">
</xsl:apply-templates>
</div>
<xsl:for-each select="Questionario/Video">
<xsl:value-of select="@Titolo"/>
<xsl:value-of select="Cast"/>
Upvotes: 0
Views: 288
Reputation: 70638
You are doing this to output the Cast
<xsl:value-of select="Cast"/>
In XSLT 1.0 this will only select the first Cast
element, but you have multiple ones. Try using xsl:for-each
instead
<xsl:for-each select="Cast">
<xsl:value-of select="." />
<br />
</xsl:for-each>
Alternatively you could use templates.
<xsl:apply-templates select="Cast" />
You would then need a template to match this
<xsl:template match="Cast">
<xsl:value-of select="." />
<br />
</xsl:template>
Upvotes: 2