Skip to content

Instantly share code, notes, and snippets.

@deckerego
Created December 6, 2013 14:18
Show Gist options
  • Save deckerego/7824930 to your computer and use it in GitHub Desktop.
Save deckerego/7824930 to your computer and use it in GitHub Desktop.
Reading an RSS XML Feed as a Dataframe
rssToDataframe <- function(uri) {
doc <- getURL(uri)
doc <- xmlParse(doc)
src <- xpathApply(doc, "/rss/channel/item")
items.df <- data.frame()
if(length(src) > 0) {
for(i in 1:length(src)) {
item <- xmlSApply(src[[i]], xmlValue)
record.df <- data.frame(t(item), stringsAsFactors=FALSE)
items.df <- rbind(items.df, record.df)
}
}
items.df$pubDate <- strptime(items.df$pubDate, "%a, %d %b %Y %H:%M:%S", tz="GMT")
return(items.df)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment