加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 扩展具有更多字段的RSS格式?

发布时间:2020-12-16 08:02:52 所属栏目:百科 来源:网络整理
导读:我有一个网站,我需要创建一个RSS提要。有没有标准的格式来添加自定义字段到RSS源?我想在我的RSS feed中添加一个“location”元素,例如。我有一些合作伙伴想要使用Feed,并能够使用我的网站特定的自定义字段。 对于当前的RSS 2.0格式,这些是RSS 2.0规范中
我有一个网站,我需要创建一个RSS提要。有没有标准的格式来添加自定义字段到RSS源?我想在我的RSS feed中添加一个“location”元素,例如。我有一些合作伙伴想要使用Feed,并能够使用我的网站特定的自定义字段。

对于当前的RSS 2.0格式,这些是RSS 2.0规范中包含的可用字段:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <channel>
    <title>RSS Example</title>
    <description>This is an example of an RSS feed</description>
    <link>http://www.domain.com/link.htm</link>
    <lastBuildDate>Mon,28 Aug 2006 11:12:55 -0400 </lastBuildDate>
    <pubDate>Tue,29 Aug 2006 09:00:00 -0400</pubDate>
    <language>en-us</language>
    <copyright>Copyright 2002,Spartanburg Herald-Journal</copyright>
    <managingEditor>geo@herald.com (George Matesky)</managingEditor>
    <webMaster>betty@herald.com (Betty Guernsey)</webMaster>
    <category>Newspapers</category>
    <generator>MightyInHouse Content System v2.3</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <image>
      <title>Something</title>
      <url>http://something.com/image.jpg</url>
      <link>http://something.com</link>
      <description>This is something</description>
    </image>
    <rating>(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~000 1))</rating>
    <item>
      <title>Item Example</title>
      <description>This is an example of an Item</description>
      <link>http://www.domain.com/link.htm</link>
      <guid> 1102345</guid>
      <pubDate>Tue,29 Aug 2006 09:00:00 -0400</pubDate>
      <author>lawyer@boyer.net (Lawyer Boyer)</author>
      <category>Grateful Dead</category>
      <comments>http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290</comments>
      <enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
      <source url="http://www.tomalak.org/links2.xml">Tomalak's Realm</source>
    </item>
  </channel>
</rss>

如果我想添加更多元素以使其可供合作伙伴使用,以便他们可以按需要消费和解析,该怎么办?同时,如果他们添加我的RSS源,我不想破解RSS阅读器。任何想法处理这个最好的方法?

据 RSS 2.0 Specification说:

“RSS originated in 1999,and has strived to be a simple,easy to
understand format,with relatively modest goals. After it became a
popular format,developers wanted to extend it using modules defined
in namespaces,as specified by the W3C.

RSS 2.0 adds that capability,following a simple rule. A RSS feed may
contain elements not described on this page,only if those elements
are defined in a namespace.”

查看文章Extending RSS 2.0 With Namespaces,其中显示了如何做到这一点。该文章的一个例子显示,作者向Feed中添加了一些自定义博客字段:

<rss version="2.0"
     xmlns="http://backend.userland.com/rss2"
     xmlns:blogChannel="http://backend.userland.com/blogChannelModule">
 <channel>
  <title>Scripting News</title>
  <link>http://www.scripting.com/</link>
  <blogChannel:blogRoll>http://radio.weblogs.com/ ... /file.opml</blogChannel:blogRoll>
  <blogChannel:mySubscriptions>http://ra ... /file.opml</blogChannel:mySubscriptions>
  <blogChannel:blink>http://inessential.com/</blogChannel:blink>
  .
  .
  .
 </channel>
 </rss>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读