I tried to parse an XML file to an R data frame. This link helped me a lot:
How to create an R data frame from an xml file?
But still I was not able to figure out my problem. Here is my code:
data <- xmlParse("http://forecast.weather.gov/MapClick.php?lat=29.803&lon=-82.411&FcstType=digitalDWML")
xmlToDataFrame(nodes=getNodeSet(data1,"//data"))[c("location","time-layout")]
step1 <- xmlToDataFrame(nodes=getNodeSet(data1,"//location/point"))[c("latitude","longitude")]
step2 <- xmlToDataFrame(nodes=getNodeSet(data1,"//time-layout/start-valid-time"))
step3 <- xmlToDataFrame(nodes=getNodeSet(data1,"//parameters/temperature"))[c("type="hourly"")]
The data frame I want to have is like this:
latitude longitude start-valid-time hourly_temperature
29.803 -82.411 2013-06-19T15:00:00-04:00 91
29.803 -82.411 2013-06-19T16:00:00-04:00 90
I'm stuck at the xmlToDataFrame()
, any help would be very much appreciated.