b = newXMLNode("bob", namespace = c(r = "http://www.r-project.org", omg = "http://www.omegahat.org", ""))
cat(saveXML(b), "")
addAttributes(b, a = 1, b = "xyz", "r:version" = "2.4.1", "omg:len" = 3)
cat(saveXML(b), "")
removeAttributes(b, "a", "r:version")
cat(saveXML(b), "")
addChildren(b, newXMLNode("el", "Red", "Blue", "Green",
attrs = c(lang ="en")))
k = lapply(letters, newXMLNode)
addChildren(b, kids = k)
cat(saveXML(b), "")
removeChildren(b, "a", "b", "c", "z")
# can mix numbers and names
removeChildren(b, 2, "e") # d and e
cat(saveXML(b), "")
i = xmlChildren(b)[[5]]
xmlName(i)
# have the identifiers
removeChildren(b, kids = c("m", "n", "q"))
# this won't work as the 10 gets coerced to a
# character vector element to be combined with 'w'
# and there is no node name 10.
removeChildren(b, kids = c(10, "w"))
Run the code above in your browser using DataLab