【发布时间】:2015-07-17 03:36:36
【问题描述】:
我有一个 RSS 提要,我正在使用 XSLT 对其进行转换,以便在我的主页上显示为 HTML。供稿的 XML 如下所示:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="News.css" ?>
<rss version="2.0">
<channel>
<title>Mutant Creations - News</title>
<link>http://www.mutantcreations.com</link>
<description>Don't worry, I'll distract the nerds. Just get back to the ship!</description>
<item>
<title>Blog Pie</title>
<pubDate>Thursday, 26 Mar 2015 21:43:00 PT</pubDate>
<link>http://www.mutantcreations.com</link>
<description>Blog is up.</description>
<story>The Motion of Thought is Mr. Mutant's blog. Check it out:<htext url="www.mutantcreations.com/Blog">Here</htext>.</story>
</item>
</channel>
</rss>
我的 XSL 看起来像这样:
<?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>News!</h2>
<xsl:for-each select="rss/channel/item">
<div style="color: #100000; padding:4px;">
<span style="font-weight:bold; text-decoration: underline;">
<xsl:value-of select="title"/>
</span>
</div>
<div style="color: #200000; padding:2px; font-size:11px;">
<span>
<xsl:value-of select="pubDate"/>
</span>
</div>
<div style="margin: 1em 0 1em 2em; margin-right:25px;font-size:12pt;">
<span>
<xsl:value-of select="story"/>
</span>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
使用相同的格式,我想获取<htext> 元素的内容并将其显示为与<story> 文本的其余部分内联的实际超链接。
<story>The Motion of Thought is Mr. Mutant's blog. Check it out:<htext url="www.mutantcreations.com/Blog">Here</htext>.</story>
此外,我如何为每个 <htext> 中的每个 <story> 元素执行此操作?
【问题讨论】:
-
htext不是超链接。您想要实际的超链接还是您发布的代码?