# NOT RUN {
doc =
xmlParse(paste0('<doc><author id="dtl"><firstname>Duncan</firstname>',
'<surname>Temple Lang</surname></author></doc>'))
au = xmlRoot(doc)[[1]]
# make a copy
other = xmlClone(au)
# change it slightly
xmlAttrs(other) = c(id = "dtl2")
# add it to the children
addChildren(xmlRoot(doc), other)
# }
Run the code above in your browser using DataLab