Forum Moderators: open
<xsl:for-each select="rss/channel/item">
<li><span class="inner">[b]<a title="<xsl:value-of select="title"/> - <xsl:value-of select="description"/>" href="<xsl:value-of select="link"/>">[/b]<span class="title"><span class="date"><xsl:value-of select="pubdate"/></span> <xsl:value-of select="title"/></span> <span class="des"><xsl:value-of select="description"/> ... Read More</span></a></span></li>
</xsl:for-each> Now you can see that the <a> tag isn't formed well. What can I do so that I can use the XSL (XML) values within the <a> tag?
You use XSL attr tags:
<A>
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="section"/>
</A>
Another example of setting XML data equal to attributes within a tag:
<img>
<xsl:attribute name="src">
<xsl:value-of select="image" />
</xsl:attribute>
<xsl:attribute name="border">
0
</xsl:attribute>
<xsl:attribute name="width">
80
</xsl:attribute>
<xsl:attribute name="height">
100
</xsl:attribute>
</img>
<xsl:for-each select="rss/channel/item">
<xsl:element name="li">
<xsl:element name="span">
<xsl:attribute name="class">inner</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="title"><xsl:value-of select="title"/></xsl:attribute>
-
<xsl:attribute name="title"><xsl:value-of select="description"/></xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
<xsl:element name="span">
<xsl:attribute name="class">title</xsl:attribute>
<xsl:element name="span">
<xsl:attribute name="class">date</xsl:attribute>
<xsl:value-of select="pubdate"/>
</xsl:element>
<xsl:value-of select="title"/>
</xsl:element>
<xsl:element name="span">
<xsl:attribute name="class">des</xsl:attribute>
<xsl:value-of select="description"/> ... Read More
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
As far as inserting values into attributes, why not just use bracket notation?
<xsl:for-each select="rss/channel/item">
<li><span class="inner"><a title="{title} - {description}" href="{link}"><span class="title"><span class="date"> <xsl:value-of select="pubdate"/></span> <xsl:value-of select="title"/></span> <span class="des"><xsl:value-of select="description"/> ... Read More</span></a></span></li>
</xsl:for-each>