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

前端之家收集整理的这篇文章主要介绍了xml – 扩展具有更多字段的RSS格式?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个网站,我需要创建一个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>

猜你在找的XML相关文章