Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically generate XML file for RSS Feed?

Tags:

python

rss

I want to create a RSS Feed generator. The generator is supposed to read data from my database and generate RSS feeds for them. I want to write a script that would automatically generate the xml file for validation.

So if a typical xml file for RSS feed looks like this:

  <item>
  <title>Entry Title</title>
  <link>Link to the entry</link>
  <guid>http://example.com/item/123</guid>
  <pubDate>Sat, 9 Jan 2010 16:23:41 GMT</pubDate>
  <description>[CDATA[ This is the description. ]]</description>
  </item>

I want the script to replace automatically the field between the <item> and the </item> tag. Similarly for all the tags. The value for the tags will be fetched from the database. So I will query for it. My app has been designed in Django.

I am looking for suggestions as to how to do this in python. I am also open to any other alternatives if my idea is vague.

like image 335
Indradhanush Gupta Avatar asked Jun 21 '13 07:06

Indradhanush Gupta


1 Answers

Since this is python. Its good to be using PyRSS2Gen. Its easy to use and generates the xml really nicely. https://pypi.python.org/pypi/PyRSS2Gen

like image 107
Indradhanush Gupta Avatar answered Sep 27 '22 23:09

Indradhanush Gupta