Rev 7747 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{xmlSerializeHook}\alias{xmlSerializeHook}\alias{xmlDeserializeHook}\title{Functions that help serialize and deserialize XML internal objects}\description{These functions can be used to controlhow the C-level data structures associated with XML documents, nodes,XPath queries, etc. are serialized to a a file or connectionand deserialized back into an R session.Since these C-level data structures are representedin R as external pointers, they would normally be serializedand deserialized in a way that loses all the information aboutthe contents of the memory being referenced.\code{xmlSerializeHook} arranges to serialize these pointersby saving the corresponding XML content as a stringand also the class of the object.The deserialize function converts such objects back to theiroriginal form.These functions are used in calls to \code{\link{saveRDS}}and \code{\link{readRDS}} via the\code{refhook} argument.\code{saveRDS(obj, filename, refhook = xmlSerializeHook)readRDS(filename, refhook = xmlDeserializeHook)}}\usage{xmlSerializeHook(x)xmlDeserializeHook(x)}\arguments{\item{x}{the object to be deserialized, and the character vector to bedeserialized.}}\value{\code{xmlSerializeHook} returns a character version of the XMLdocument or node, along with the basic class.If it is called with an object that is not an native/internal XMLobject, it returns \code{NULL}\code{xmlDeserializeHook} returns the parsed XML object, either adocument or a node.}\references{The R Internals Manual.}\author{Duncan Temple Lang}\seealso{\code{\link{saveRDS}} and \code{\link{readRDS}}}\examples{z = newXMLNode("foo")f = system.file("exampleData", "tides.xml", package = "XML")doc = xmlParse(f)hdoc = as(doc, "XMLHashTree")nodes = getNodeSet(doc, "//pred")ff <- file.path(tempdir(), "tmp.rda")saveRDS(list(a = 1:10, z = z, doc = doc, hdoc = hdoc, nodes = nodes), ff,refhook = xmlSerializeHook)v = readRDS(ff, refhook = xmlDeserializeHook)unlink(ff)}\keyword{IO}