fileName <- system.file("exampleData", "mtcars.xml", package="XML")
doc <- xmlTreeParse(fileName)
xmlAttrs(xmlRoot(doc))
xmlAttrs(xmlRoot(doc)[["variables"]])
doc <- xmlTreeParse(fileName, useInternalNodes = TRUE)
d = xmlRoot(doc)
xmlAttrs(d)
xmlAttrs(d) <- c(name = "Motor Trend fuel consumption data",
author = "Motor Trends")
xmlAttrs(d)
# clear all the attributes and then set new ones.
removeAttributes(d)
xmlAttrs(d) <- c(name = "Motor Trend fuel consumption data",
author = "Motor Trends")
Run the code above in your browser using DataLab