getRSS.R

Uploaded by:fwild

              
getRSS <- function (url) {
  
  # -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  
  # fetch and parse the rss feed

  rss = xmlTreeParse(url)
  src = xpathApply(xmlRoot(rss), "//item")

  fields = c("title","description","link", "pubDate", "guid")
  for (i in 1:length(src)) {
  
    if (i==1) {
      item = xmlSApply(src[[i]], xmlValue)
      feed = data.frame(t(item[fields]), stringsAsFactors=FALSE)
    } else {
      item = xmlSApply(src[[i]], xmlValue)
      tmp = data.frame(t(item[fields]), stringsAsFactors=FALSE)
      feed = rbind(feed, tmp)
    }
  
  } # for each item
  
  return(feed)

}

getRSS("http://learningfrontiers.eu/extras/mediabase/feeds/bursty/")