【发布时间】:2014-05-20 16:46:33
【问题描述】:
我有一个分两页显示的 XML 文件。主页仅显示 XML 文件的 TITLES,秒页面显示所有 XML 项,但带有 Title、Date 和 Description。
当从主页单击标题时,我希望它转到第二页并直接转到呈现为 XSLT 的那个 ITEM。
我相信使用锚是一种方式,但我不知道如何使用 XML。
XML
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<generator>Easy Feed Editor</generator>
<title>RSS Feed</title>
<description>Welcome to the Site</description>
<link>www.website.com</link>
<image><url>http://www.website.com/images/logo2.jpg</url><title> RSS Feed</title>
<link>www.website.com</link></image>
<language>en-us</language>
<pubDate>Tue, 20 May 2014 13:39:17 GMT</pubDate>
<managingEditor>TCPC</managingEditor>
<item>
<title>NEW YEAR'S DAY
</title>
<description>
<![CDATA[<p>
We will resume regular business hours on Thursday, January 2, 2014. </p>
]]></description>
<link>http://www.website.com/PT/news.aspx</link>
<author>PC</author>
<guid isPermaLink="false">0d8a3208-0900-45ad-84f4-4934a751aac3</guid>
<pubDate>Tue, 20 May 2014 13:38:21 GMT</pubDate>
<enclosure url="http://www.website.com/images/logo2.jpg" type="image/jpeg" length="16645" />
</item>
<item>
<title>SAVE BIG</title>
<description><![CDATA[<p>
Pay big description goes here. Sample text. </p>
]]></description>
<link>http://www.website.com/PT/news.aspx</link>
<author>PC</author>
<guid isPermaLink="false">4428636c-218d-46d3-98bd-52e83e27e02f</guid>
<pubDate>Mon, 16 Dec 2013 13:40:26 GMT</pubDate>
<enclosure url="http://www.website.com/images/logo2.jpg" type="image/jpeg" length="16645" />
</item>
<item>
<title>NEW OFFICE</title>
<description><![CDATA[<p>
Office Description</p>
]]></description>
<link>http://www.website.com/PT/news.aspx</link>
<author>PC</author>
<guid isPermaLink="false">45a6ca63-8bad-4b60-bd0a-69190089b789</guid>
<pubDate>Fri, 06 Dec 2013 21:34:49 GMT</pubDate>
<enclosure url="http://www.website.com/images/logo2.jpg" type="image/jpeg" length="16645" />
</item>
</channel>
</rss>
XSLT
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<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;">
<xsl:value-of select="title"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
<br></br>
<h5 style="font-style:italic">
<xsl:value-of select="pubDate"/>
</h5>
<br></br>
<p>
<span style ="font: normal 14px/1.5 'Segoe UI'">
<xsl:value-of select="description"/>
</span>
</p>
</div>
</xsl:for-each>
</html>
</xsl:template>
</xsl:stylesheet>
【问题讨论】:
-
我的回答对你有用吗?