RSS2 - 让浏览器阅读器显示它
我有一个简单且经过验证的 RSS2 测试文档,其中包含两个“项目”。
我在网页的头部有一个 RSS“链接”元素,指向 RSS2 XML 页面。
我在该网页的内容中有一个 RSS 按钮,其中有一个普通的 href 指向 RSS2 XML 页面。
在 Safari 中 --
如果我单击浏览器地址栏中的 Safari 的“RSS”图标,我会按预期获得 Safari RSS 阅读器,但只会出现两个“项目”中的第一个(如果我注释掉第一个项目) ,然后会出现第二个项目)
如果我单击我的内容 RSS 按钮,我会在浏览器窗口中获取原始 XML 代码
在 Firefox 中,
- 如果我单击浏览器地址栏中的 Firefox 联合图标,或我的内容 RSS 按钮,我会得到“此 XML 文件似乎没有与之关联的任何样式信息”文档树如下所示。”
I have a simple and validated RSS2 test document with two "items".
I have an RSS "link" element in the head section of a web page pointing to the RSS2 XML page.
I have an RSS button in the content of that web page, with a normal href pointing to the RSS2 XML page.
In Safari --
if I click on Safari's "RSS" icon in the browser address bar, I get the Safari RSS reader as expected, but only the first of the two "items" appears (if I comment out that first item, then the second item appears instead)
if I click on my content RSS button, I get the raw XML code in the browser window
In Firefox --
- if I click on either Firefox's syndication icon in the browser address bar, or on my content RSS button, I get "This XML file does not appear to have any style information associated with it. The document tree is shown below."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许不同的浏览器可以解决您的问题。
Maybe a different browser would solve your problems.
您需要确保发送适当的 MIME 类型 HTTP 标头。
是相当标准的。
Safari 问题可能是由侧边栏中的日期过滤器引起的。确保您选择了“全部”。
You need to make sure you're sending an appropriate MIME type HTTP header.
is fairly standard.
The Safari problem may be caused by the date filter in the sidebar. Make sure you've got "All" selected.
(我没有 SO 帐户,所以我无法向我原来的问题或其他答案添加评论。谢谢 grahamparks,你给了我正确的提示。)
为每个“项目”使用唯一的“guid”已经解决了Safari 中只出现一项的问题。
其他问题只需将文件放在网络服务器上即可解决。
令人惊讶的是,这似乎不是 mime 类型问题——即使 RSS 文件作为 text/html 提供,浏览器的 RSS 阅读器也会正确显示 RSS 文档。所以我猜测浏览器 RSS 阅读器一定不喜欢本地“file://”地址(在 Mac 上)。
(I don't have an SO account so I can't add comments to my original question or other answers. Thanks grahamparks, you got me on the right tip.)
Using a unique "guid" for each "item" has solved the problem of only one item appearing in Safari.
The other problems have been solved just by putting the files up on a web server.
Surprisingly it doesn't seem to be a mime type issue though -- the browsers' RSS readers kick in to display the RSS doc properly even if the RSS file is served as text/html. So I'm guessing it must be that the browser RSS readers don't like local "file://" addresses (on Mac).