How to extract data from an RSS feed in Rockets

Post #: 80
Post type: Blog post
Date: 2013-01-25 14:12:04.000
Author: Rocket Man

RSS feeds are useful and great, but the XML structure they come in is rather unwieldy to read through and parse. newLISP has a great function called (parse-xml) that converts an XML tree into a list, but now you just have an unwieldy list. It's helpful to be able to extract only the data we want and put it in a simple nested list.

I've written a new function in Rockets that lets you do just that.

First, get the data from the RSS feed URL that you want:

(set 'feed-url "";))
(set 'rss-result (xml-parse (get-url feed-url)))

Now, we want to extract the fields "title", "author", and "link" from that feed.

(set 'field-result (get-fields-from-rss rss-result '("title" "author" "link")))

(field-result) will return the following:

(("News Post: The Book Of Divine Wisdom" " (Tycho)" "";)
("News Post: So many games!" " (Gabe)" "";)
...etc ... )

If a field isn't present in the RSS data, (field-result) will populate that part of the list with the "nil" value instead.

NOTE: Remove the spurious ";" characters in the example code here before running it

Happy RSSing!

View this post in the forums

Views: 6001