Skip to content

Instantly share code, notes, and snippets.

@deckerego
Created December 6, 2013 14:18
Show Gist options
  • Save deckerego/7824973 to your computer and use it in GitHub Desktop.
Save deckerego/7824973 to your computer and use it in GitHub Desktop.
Reading an RSS Atom Feed as a Dataframe
atomToDataframe <- function(uri) {
doc <- getURL(uri)
doc <- xmlParse(doc)
src <- getNodeSet(doc, "/d:feed/d:entry", c(d = "http://www.w3.org/2005/Atom"))
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$published <- strptime(items.df$published, "%Y-%m-%dT%H:%M:%S", tz="UTC")
items.df$updated <- strptime(items.df$updated, "%Y-%m-%dT%H:%M:%S", tz="UTC")
return(items.df)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment