issue with making data.frame from xml file



I'm having my first go at transforming XML to an R data.frame and have found questions such as this one: How to transform XML data into a data.frame? very helpful, but still am unable to my piece of XML into a data.frame.


My aim is to make a plot of Euro to US Dollar exchange rates over time. The data is listed here in XML format:


http://ift.tt/1yVit4m


I'm able to read in the data and show which part of the data (node?) I'm interested in:



library(XML)
doc <- xmlTreeParse("http://ift.tt/1yVit4m")
root <- xmlRoot(doc)
root[[2]][[2]]


I've tried variations of getNodeSet() to show all of the lines that start with , but sofar to no avail:



getNodeSet(root, "/DataSet/Series/*")
getNodeSet(root, "//obs")
getNodeSet(root, "//obs[@OBS_VALUE = 1.1789]")


How do I go about to extract all or the variables TIME_PERIOD and OBS_VALUE from this XML file and put them into an R data.frame? Thanks already for any comments or clarifications.


No comments:

Post a Comment