long = runif(10000, -122, -80)
lat = runif(10000, 25, 48)
txt = sprintf("<Placemark><Point><coordinates>%.3f,%.3f,0</coordinates></Point></Placemark>",
long, lat)
f = newXMLNode("Folder")
parseXMLAndAdd(txt, f)
xmlSize(f)
# this version is much slower as i) we don't vectorize the
# creation of the XML nodes, and ii) the parsing of the XML
# as a string is very fast as it is done in C.
f = newXMLNode("Folder")
mapply(function(a, b) {
newXMLNode("Placemark",
newXMLNode("Point",
newXMLNode("coordinates",
paste(a, b, "0", collapse = ","))),
parent = f)
},
long, lat)
xmlSize(f)
Run the code above in your browser using DataLab