RSS 和 Atom 协议详解


Author: yifei / Created: Dec. 27, 2016, 7:35 p.m. / Modified: Nov. 13, 2017, 7:36 p.m. / Edit

关于CDATA

CDATA stands for Character Data and it means that the data in between these strings includes data that could be interpreted as XML markup, but should not be.

So we could use CDATA to smuggle some HTML into the XML document, so that the HTML doesn't confuse the XML document structure, and then use XSLT later to pull it out and spit it into a HTML document that is being output.   In short, you don't have to escape all the < and & in CDATA section  

RSS 2.0

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>Example Feed</title>
        <description>Insert witty or insightful remark here</description>
        <link>http://example.org/</link>
        <lastBuildDate>Sat, 13 Dec 2003 18:30:02 GMT</lastBuildDate>
        <managingEditor>johndoe@example.com (John Doe)</managingEditor>
        <item>
            <title>Atom-Powered Robots Run Amok</title>
            <link>http://example.org/2003/12/13/atom03</link>
            <pubDate>Sat, 13 Dec 2003 18:30:02 GMT</pubDate>
            <description>Some text.</description>
            <source>Shit News</source>
        </item>
        <item>...</item>
    </channel>
</rss>

RSS 协议的一些不足

没有标识文章重要度的字段

没有途径把订阅数量等信息反馈给 RSS 提供方

没有品牌特性

没有机器推荐

如果能够把 RSS 包装成像是 Amazon Prime 那样的服务,用户可能会很愿意付钱    

Atom 1.0

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Example Feed</title>
    <subtitle>Insert witty or insightful remark here</subtitle>
    <link href="http://example.org/"/>
    <updated>2003-12-13T18:30:02Z</updated>
    <author>
        <name>John Doe</name>
        <email>johndoe@example.com</email>
    </author>
    <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
 
    <entry>
        <title>Atom-Powered Robots Run Amok</title>
        <link href="http://example.org/2003/12/13/atom03"/>
        <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
        <updated>2003-12-13T18:30:02Z</updated>
        <summary>Some text.</summary>
    </entry>
 
</feed>

 

reference

  [1] http://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared


评论区