[英]Get data from XSL Value-Of and put in <a> link
I am trying to get the value of Car in my XML file and use that value in tag link. 我正在尝试在XML文件中获取Car的值,并在标记链接中使用该值。 Or how do you get that value and use it. 或者,您如何获得该价值并加以利用。
<xsl:for-each select="rss/channel/item">
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
var #link = <xsl:value-of select="Car"/>
/*How do I do this?*/
<a id ="#link "> </a>
</span>
</div>
</xsl:for-each>
</html>
You can use an Attribute Value Template for that: 您可以为此使用属性值模板 :
<xsl:for-each select="rss/channel/item">
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
<a name ="{Car}"></a>
</span>
</div>
</xsl:for-each>
You can also do it with an <xsl:attribute>
: 您也可以使用<xsl:attribute>
:
<xsl:for-each select="rss/channel/item">
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
<a>
<xsl:attribute name="name"><xsl:value-of select="Car"/></xsl:attribute>
</a>
</span>
</div>
</xsl:for-each>
I was assuming an <a name=""></a>
anchor. 我假设使用<a name=""></a>
锚点。 But you could do the same with an <a href="">
hyperlink: 但是您可以使用<a href="">
超链接执行相同的操作:
<a href="#{Car}">link</a>
or ID: 或ID:
<span id="{Car}">object</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.