[R] using XML package to read RSS

J Toll jctoll at gmail.com
Thu May 17 03:40:02 CEST 2012


Hi,

I'm trying to use the XML package to read an RSS feed.  To get
started, I was trying to use this post as an example:

http://www.r-bloggers.com/how-to-build-a-dataset-in-r-using-an-rss-feed-or-web-page/

I can replicate the beginning section of the post, but when I try to
use another RSS feed I have an issue.  The RSS feed I would like to
use is:

> URL <- "http://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent&type=&company=&dateb=&owner=include&start=0&count=40&output=atom"

> library(XML)
> doc <- xmlTreeParse(URL)

> src <- xpathApply(xmlRoot(doc), "//entry")

I get an empty list rather than a list of each of the "entry":

> src
list()
attr(,"class")
[1] "XMLNodeSet"

I'm not sure how to fix this.  Any suggestions?  Do I need to provide
a namespace, or is the RSS malformed?

Thanks,


James



More information about the R-help mailing list