Created
December 6, 2013 14:18
-
-
Save deckerego/7824973 to your computer and use it in GitHub Desktop.
Reading an RSS Atom Feed as a Dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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