I am after the names of the stores and the coordinates of the stores from: http://contact.woolworths.com.au/storelocator/service/proximity/supermarkets/latitude/-37.7510/longitude/144.8981/range/50/max/200.xml
e.g.
<name>Niddrie</name>
<latitude>-37.737332</latitude>
<longtitude>144.892342</longtitude>
How would I do this? I have tried these:
library(XML)
library(methods)
library(xml2)
#https://stackoverflow.com/questions/17198658/how-to-parse-xml-to-r-data-frame
data <- xmlParse("http://contact.woolworths.com.au/storelocator/service/proximity/supermarkets/latitude/-37.7510/longitude/144.8981/range/50/max/200.xml")
xml_data <- xmlToList(data)
location <- as.list(xml_data[["storeList"]][["storeRank"]][["storeDetail"]][["Name"]])
#https://www.datacamp.com/community/tutorials/r-data-import-tutorial#xml - not working
xmlfile <- xmlTreeParse("http://contact.woolworths.com.au/storelocator/service/proximity/supermarkets/latitude/-37.7510/longitude/144.8981/range/50/max/200.xml")
class(xmlfile)
topxml <- xmlRoot(xmlfile)
topxml <- xmlSApply(topxml,
function(x) xmlSApply(x, xmlValue))
xml_df <- data.frame(t(topxml),
row.names=NULL)
For both, there is no error, but not the names that I want. Same with the coordinates.