Create a copy of an internal XML document or node
These methods allow the caller to create a copy of an XML internal node. This is useful, for example, if we want to use the node or document in an additional context, e.g. put the node into another document while leaving it in the existing document. Similarly, if we want to remove nodes to simplify processing, we probably want to copy it so that the changes are not reflected in the original document.
At present, the newly created object is not garbage collected.
the object to be cloned
a logical value indicating whether the
entire object and all its descendants should be duplicated/cloned (
typically a logical value indicating whether to bring this
new object under R's regular garbage collection.
This can also be a reference to a C routine which is to be used as
the finalizer. See
additional parameters for methods
A new R object representing the object.
Duncan Temple Lang
1 2 3 4 5 6 7 8 9 10
doc = xmlParse('<doc><author id="dtl"><firstname>Duncan</firstname><surname>Temple Lang</surname></author></doc>') au = xmlRoot(doc)[] # make a copy other = xmlClone(au) # change it slightly xmlAttrs(other) = c(id = "dtl2") # add it to the children addChildren(xmlRoot(doc), other)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.