David Z
David Z

Reputation: 131730

Creating RSS/Atom feeds: template language or XML library?

I'm creating an RSS (and/or Atom) feed for my website. Now, I can immediately think of two ways to do this:

  1. Use the same templating system I use to generate the HTML (Clearsilver if anyone's wondering), basically just treating the RSS feed like any other web page that happens to be in RSS+XML instead of XHTML
  2. Use an XML library, or an RSS library specifically, in my programming language of choice (Python) to create the feed programmatically and then write it out

Are there particular reasons to choose one approach over the other? From initial impressions, I'm leaning toward option 1, mostly because it's easier to understand.

EDIT: so I got one good answer from Bill. But in this particular case all the values for the fields of the RSS feed are already formatted as well-formed, properly escaped XHTML... any other opinions?

Upvotes: 0

Views: 628

Answers (2)

rabble
rabble

Reputation: 431

Template are often faster and easier but if you want to make sure you generate valid xml and rss/atom then you should use the xml library. If you write a test which validates your template generated xml then you should be fine.

Upvotes: 0

Bill
Bill

Reputation: 3672

Having done it both ways, I prefer #2. It'll do a better job escaping entities as needed, ensuring you produce well-formed XML, etc.

Upvotes: 3

Related Questions