[R] Trouble with reading xml in R

Dorte Klerke dklerke at hotmail.com
Tue Apr 30 18:12:17 CEST 2013


 Hi I have been trying for days now to read the contents of this xml file into
R. I tried the simpler solution xmlToDataFrame, which worked on another
file, but somehow it doesn't work for this file. 
 
I have tried different other solutions, but I just can't seem to get it
quite right. 
 
doc <- xmlRoot(xmlTreeParse(url)) 
art <- doc[[1]] [["DeliveryDay"]] 
fields <- xmlApply(art[[2]]), names) 
 
unique(names(unlist(fields))) 
 
Gives output: 
> "TimeStepID.text" "Purchase.Price" "Purchase.Volume" "Sell.Price"
> "Sell.Volume" 
 
 
So I want the result to be a 2 data.frames which looks like this (of course
for the sell data.fram it would say sell) 
 
 
TimeStepID   Purchase.Price    Purchase.Volume 
1                              3000                          13000 
1                              2900                          13400 
----- 
24                           2000                           12333 
 
etc. 
 
How is this possible? 
 
 
Also an extra question. My filename is called something like (a new file
every day) 
 
BidAskCurves_DE-AU_20130425_20130424130349.xml 
 
The first part after the "AU" is the current date, this I can generate
automacticly but I can't generate the last since its the date, time, minute
and second of the time the data was uploaded from another party to their ftp
- where I'm getting the data. 
 
Is there anyway to get R to find the right file, when I can only generate
part of the file? 
 		 	   		  


More information about the R-help mailing list