long = runif(10000, -122, -80)
lat = runif(10000, 25, 48)
txt = sprintf("%.3f,%.3f,0",
long, lat)
f = newXMLNode("Folder")
parseXMLAndAdd(txt, f)
xmlSize(f)
if (FALSE) {
# 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)
o = c("dog", "cat")
node = parseXMLAndAdd(o, nsDefs = c("http://cran.r-project.org",
omg = "https://www.omegahat.net"))
xmlNamespace(node[[1]])
xmlNamespace(node[[2]])
tt = newXMLNode("myTop")
node = parseXMLAndAdd(o, tt, nsDefs = c("http://cran.r-project.org",
omg = "https://www.omegahat.net"))
tt
}
Run the code above in your browser using DataLab