File: version-detection.html

package info (click to toggle)
nodebox-web 1.9.2-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,724 kB
  • ctags: 1,254
  • sloc: python: 6,161; sh: 602; xml: 239; makefile: 33
file content (111 lines) | stat: -rw-r--r-- 8,225 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Feed Type and Version Detection [Universal Feed Parser]</title>
<link rel="stylesheet" href="feedparser.css" type="text/css">
<link rev="made" href="mailto:mark@diveintomark.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.65.1">
<meta name="keywords" content="RSS, Atom, CDF, XML, feed, parser, Python">
<link rel="start" href="index.html" title="Documentation">
<link rel="up" href="advanced.html" title="Advanced Features">
<link rel="prev" href="resolving-relative-links.html" title="Relative Link Resolution">
<link rel="next" href="character-encoding.html" title="Character Encoding Detection">
</head>
<body id="feedparser-org" class="docs">
<div class="z" id="intro"><div class="sectionInner"><div class="sectionInner2">
<div class="s" id="pageHeader">
<h1><a href="/"><span>Universal Feed Parser</span></a></h1>
<p><span>Parse RSS and Atom feeds in Python.  3000 unit tests.  Open source.</span></p>
</div>
<div class="s" id="quickSummary"><ul>
<li class="li1">
<a href="http://sourceforge.net/projects/feedparser/"><span>Download</span></a> ·</li>
<li class="li2">
<a href="http://feedparser.org/docs/"><span>Documentation</span></a> ·</li>
<li class="li3">
<a href="http://feedparser.org/tests/"><span>Unit tests</span></a> ·</li>
<li class="li4"><a href="http://sourceforge.net/tracker/?func=browse&amp;group_id=112328&amp;atid=661937"><span>Report a bug</span></a></li>
</ul></div>
</div></div></div>
<div id="main"><div id="mainInner">
<p id="breadcrumb">You are here: <a href="index.html">Documentation</a> → <a href="advanced.html">Advanced Features</a> → <span class="thispage">Feed Type and Version Detection</span></p>
<div class="section" lang="en">
<div class="titlepage">
<div>
<div><h2 class="title">
<a name="advanced.version" class="skip" href="#advanced.version" title="link to this section"><img src="images/permalink.gif" alt="[link]" title="link to this section" width="8" height="9"></a> Feed Type and Version Detection</h2></div>
<div><div class="abstract">
<h3 class="title"></h3>
<p><span class="application">Universal Feed Parser</span> attempts to autodetect the type and version of the feeds it parses.  There are many subtle and not-so-subtle differences between the different versions of <acronym title="Rich Site Summary">RSS</acronym>, and applications may choose to handle different feed types in different ways.</p>
</div></div>
</div>
<div></div>
</div>
<div class="example">
<a name="example.version" class="skip" href="#example.version" title="link to this example"><img src="images/permalink.gif" alt="[link]" title="link to this example" width="8" height="9"></a> <h3 class="title">Example: Accessing feed version</h3>
<pre class="screen"><tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d = feedparser.parse('<a href="http://feedparser.org/docs/examples/atom10.xml">http://feedparser.org/docs/examples/atom10.xml</a>')</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d.version</span>
<span class="computeroutput">'atom10'</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d = feedparser.parse('<a href="http://feedparser.org/docs/examples/atom03.xml">http://feedparser.org/docs/examples/atom03.xml</a>')</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d.version</span>
<span class="computeroutput">'atom03'</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d = feedparser.parse('<a href="http://feedparser.org/docs/examples/rss20.xml">http://feedparser.org/docs/examples/rss20.xml</a>')</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d.version</span>
<span class="computeroutput">'rss20'</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d = feedparser.parse('<a href="http://feedparser.org/docs/examples/rss20dc.xml">http://feedparser.org/docs/examples/rss20dc.xml</a>')</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d.version</span>
<span class="computeroutput">'rss20'</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d = feedparser.parse('<a href="http://feedparser.org/docs/examples/rss10.rdf">http://feedparser.org/docs/examples/rss10.rdf</a>')</span>
<tt class="prompt">&gt;&gt;&gt; </tt><span class="userinput">d.version</span>
<span class="computeroutput">'rss10'</span></pre>
</div>
<p>Here is the complete list of known feed types and versions that may be returned in <tt class="varname">version</tt>:</p>
<div class="variablelist"><dl>
<dt><span class="term"><tt class="constant">rss090</tt></span></dt>
<dd><a href="http://www.purplepages.ie/RSS/netscape/rss0.90.html"><acronym title="Rich Site Summary">RSS</acronym> 0.90</a></dd>
<dt><span class="term"><tt class="constant">rss091n</tt></span></dt>
<dd><a href="http://my.netscape.com/publish/formats/rss-spec-0.91.html">Netscape <acronym title="Rich Site Summary">RSS</acronym> 0.91</a></dd>
<dt><span class="term"><tt class="constant">rss091u</tt></span></dt>
<dd>
<a href="http://backend.userland.com/rss091">Userland <acronym title="Rich Site Summary">RSS</acronym> 0.91</a> (<a href="http://diveintomark.org/archives/2004/02/04/incompatible-rss#example3">differences from Netscape <acronym title="Rich Site Summary">RSS</acronym> 0.91</a>)</dd>
<dt><span class="term"><tt class="constant">rss10</tt></span></dt>
<dd><a href="http://purl.org/rss/1.0/"><acronym title="Rich Site Summary">RSS</acronym> 1.0</a></dd>
<dt><span class="term"><tt class="constant">rss092</tt></span></dt>
<dd><a href="http://backend.userland.com/rss092"><acronym title="Rich Site Summary">RSS</acronym> 0.92</a></dd>
<dt><span class="term"><tt class="constant">rss093</tt></span></dt>
<dd><a href="http://backend.userland.com/rss093"><acronym title="Rich Site Summary">RSS</acronym> 0.93</a></dd>
<dt><span class="term"><tt class="constant">rss094</tt></span></dt>
<dd>
<acronym title="Rich Site Summary">RSS</acronym> 0.94 (no accurate specification is known to exist)</dd>
<dt><span class="term"><tt class="constant">rss20</tt></span></dt>
<dd><a href="http://blogs.law.harvard.edu/tech/rss"><acronym title="Rich Site Summary">RSS</acronym> 2.0</a></dd>
<dt><span class="term"><tt class="constant">rss</tt></span></dt>
<dd>
<acronym title="Rich Site Summary">RSS</acronym> (unknown or unrecognized version)</dd>
<dt><span class="term"><tt class="constant">atom01</tt></span></dt>
<dd><a href="http://www.intertwingly.net/blog/1506.html">Atom 0.1</a></dd>
<dt><span class="term"><tt class="constant">atom02</tt></span></dt>
<dd><a href="http://diveintomark.org/public/2003/08/atom02spec.txt">Atom 0.2</a></dd>
<dt><span class="term"><tt class="constant">atom03</tt></span></dt>
<dd><a href="http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html">Atom 0.3</a></dd>
<dt><span class="term"><tt class="constant">atom10</tt></span></dt>
<dd><a href="http://www.ietf.org/rfc/rfc4287">Atom 1.0</a></dd>
<dt><span class="term"><tt class="constant">atom</tt></span></dt>
<dd>Atom (unknown or unrecognized version)</dd>
<dt><span class="term"><tt class="constant">cdf</tt></span></dt>
<dd><a href="http://www.w3.org/TR/NOTE-CDFsubmit.html"><acronym title="Channel Definition Format">CDF</acronym></a></dd>
<dt><span class="term"><tt class="constant">hotrss</tt></span></dt>
<dd><a href="http://diveintomark.org/archives/2004/04/14/hot-rss">Hot <acronym title="Rich Site Summary">RSS</acronym></a></dd>
</dl></div>
<p>If the feed type is completely unknown, <tt class="varname">version</tt> will be an empty string.</p>
</div>
<div style="float: left">← <a class="NavigationArrow" href="resolving-relative-links.html">Relative Link Resolution</a>
</div>
<div style="text-align: right">
<a class="NavigationArrow" href="character-encoding.html">Character Encoding Detection</a> →</div>
<hr style="clear:both">
<div class="footer"><p class="copyright">Copyright © 2004, 2005, 2006 Mark Pilgrim</p></div>
</div></div>
</body>
</html>