Django

Code

Ticket #6039: atom_feed.txt

File atom_feed.txt, 1.1 kB (added by Ion Morega <ion.morega@gmail.com>, 7 months ago)

sample code that generates a valid ATOM feed

Line 
1 >>> from django.utils import feedgenerator
2 >>> f = feedgenerator.Atom1Feed(
3 ...     title=u"My Weblog",
4 ...     link=u"http://www.example.com/",
5 ...     description=u"In which I write about what I ate today.",
6 ...     language=u"en",
7 ...     author_name=u"Myself",
8 ...     feed_url=u"http://www.example.com/atom.xml")
9 >>> f.add_item(title=u"Hot dog today",
10 ...     link=u"http://www.example.com/entries/1/",
11 ...     description=u"<p>Today I had a Vienna Beef hot dog. It was pink, plump and perfect.</p>")
12 >>> print f.writeString('utf-8')
13 <?xml version="1.0" encoding="utf-8"?>
14 <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title>My Weblog</title>
15 <link href="http://www.example.com/" rel="alternate"></link>
16 <link href="http://www.example.com/atom.xml" rel="self"></link><id>http://www.example.com/</id>
17 <updated>2007-11-27T21:42:51Z</updated><author><name>Myself</name></author><entry><title>Hot dog today</title>
18 <link href="http://www.example.com/entries/1/" rel="alternate"></link><id>tag:www.example.com/entries/1/</id>
19 <summary type="html">&lt;p&gt;Today I had a Vienna Beef hot dog. It was pink, plump and perfect.&lt;/p&gt;</summary>
20 </entry></feed>