Using R to download and read zipped xml file



Based on this answer by Dirk Eddelbuettel I am trying to read an xml file from a zip archive for further processing. Apart from URL and filenames the only change to the code referenced is that I changed read.table to xmlInternalTreeParse.



library(XML)
temp <- tempfile()
download.file("http://ift.tt/1oCY11X",temp)
doc <- xmlInternalTreeParse(unz(temp, "nrg_105a.dsd.xml"))
fileunlink(temp)
closeAllConnections()


However, this returns the following error:



Error in file.exists(file) : invalid 'file' argument


traceback()shows that this is a function call from within the parser. So temp seems to be an inappropriate reference in this context. Is there a way to make this work?


No comments:

Post a Comment