I'm trying to get R to download the data from here:

http://www.usda.gov/oce/commodity/wasde/report_format/latest-July-2015-New-Format.xml


# install and load the necessary package
install.packages("XML")
library(XML)
# Save the URL of the xml file in a variable

xml.url <- 
"http://www.usda.gov/oce/commodity/wasde/report_format/latest-July-2015-New-Format.xml";
# Use the xmlTreePares-function to parse xml file directly from the web

xmlfile <- xmlTreeParse(xml.url)
# the xml file is now saved as an object you can easily work with in R:
class(xmlfile)


# Use the xmlRoot-function to access the top node
xmltop = xmlRoot(xmlfile)
# have a look at the XML-code of the first subnodes:
print(xmltop)[1:3]



Everything seems fine up to that point.  The next line seems to NOT parse the 
data as I thought it would.
# To extract the XML-values from the document, use xmlSApply:
datacat <- xmlSApply(xmltop, function(x) xmlSApply(x, xmlValue))



I did some research on this, and it seemed to work in other examples of xml 
data. I guess this data set is different...or I just don't understand this well 
enough to know what's really going on...

Basically, I want to get this:

xmltop


Into a data table. How can I do that?

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to