i'm learning xslt using simple example has xml records in format:
<cd> <title>hide heart</title> <artist>bonnie tyler</artist> <country>uk</country> <company>cbs records</company> <price>9.90</price> <year>1988</year> </cd>
the following xslt working return records in xml html table:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <html> <body> <h2>my cd collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th style="text-align:left">title</th> <th style="text-align:left">artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
i've been asked include value of country field first xml record in title header (the country have same value records).
i've tried following it's not working:
<th style="text-align:left">title <xsl:value-of select="country"/></th>
i've never had retrieve value xml out of "for-each" loop before not sure correct syntax or if it's possible?
try:
<xsl:value-of select="catalog/cd[1]/country"/>
Comments
Post a Comment