RSS未在Chrome中显示

时间:2012-08-31 15:35:31

标签: css google-chrome xslt web rss

我正在尝试使用我创建的RSS Feed。它有两个链接的css和xls文档,一个css作为故障安全,如果xsl不起作用,另一个css表示xls格式化feed。 网址在这里:

http://rockthepatch.com/rss/current-events.xml

rss Feed看起来像这样:

<?xml version="1.0" encoding="iso-8859-1"?>

<?xml-stylesheet type="text/css" href="http://www.rockthepatch.com/css/rss.css"?>
<?xml-stylesheet type="text/xsl" href="http://www.rockthepatch.com/rss/current-events.xsl"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <language>en-us</language>
    <title>Upcoming Rock the Patch! Events</title>
    <link>http://www.rockthepatch.com/rss/current-events.xml</link>
    <description>See what's coming up below:</description>
    <atom:link href="http://www.rockThePatch.com/rss/current-events.xml" rel="self"     type="application/rss+xml" />

    <item>
      <title>Thursday's Open Mic at Ole Simms</title>
      <link>https://www.facebook.com/olesimrells</link>
      <description>Join Patches at open mic night at Terre Haute's Ole Simmerls Bar around 9 P.M. every Thursday.</description>
      <guid>http://www.indstate.edu/mpa/sarah/rockThePatch/rss/item0001</guid>
      <pubDate>Mon, 10 Oct 2011 09:15:00 EST</pubDate>
      <author>sklinefelter89@gmail.com (Patches)</author>
    </item>
    <item>
      <title>Fall Break is Here!</title>
      <link>http://www.indstate.edu/academicaffairs/calendar.htm</link>
      <description>School and work will not happen on Friday due to FALL BREAK!!!    </description>
      <guid>http://www.indstate.edu/mpa/sarah/rockThePatch/rss/item0002</guid>
      <pubDate>Fri, 07 Oct 2011 02:23:00 EST</pubDate>
      <author>sklinefelter89@gmail.com (Patches)</author>
    </item>
  </channel>
</rss>

xsl看起来像这样:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <head>
          <link rel="stylesheet" href="http://www.rockthepatch.com/css/xsl.css"     type="text/css"/>
      </head>
      <body>
        <h2>Upcoming Rock the Patch! Events</h2>
        <table border="1px">
          <tr>
            <th>Name of Event</th>
            <th>Description</th>
            <th>Date Posted</th>
            <th>Author</th>
         </tr>
      <xsl:for-each select="rss/channel/item">
        <tr>
              <td>
            <xsl:value-of select="title"/>
          </td>
          <!-- <td>
            <a href="&lt;xsl:value-of select='link'/&gt;" title="Link">
              <xsl:value-of select="link"/>
            </a>
          </td> -->
          <td>
            <xsl:value-of select="description"/>
          </td>
          <td>
            <xsl:value-of select="pubDate"/>
          </td>
          <td>
                <a href="mailto:sklinefelter89@gmail.com" title="sklinefelter89@gmail.com">
                  <xsl:value-of select="author"/>
                </a>
              </td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>

我不希望文件下载,但每次点击链接时,它都会下载而不是在任何浏览器中显示...有人可以指出我做错了吗?

1 个答案:

答案 0 :(得分:0)

我检查了您网址中的HTTP标头。您发送的内容类型为application/xhtml+xml。您应该将其更改为application/rss+xml。那个应该做到这一点。

我将您的xml文件放在coldfusion服务器上以重新解决该问题。然后将扩展名更改为cfm,添加了<cfcontent type = "application/rss+xml">,并且它可以按照您的需要工作(无需下载)。