Serializing XML objects to connections.
Arguments
- object
R object to serialize.
- connection
an open connection or (for
serialize
)NULL
or (forunserialize
) a raw vector (see ‘Details’).- ...
Additional arguments passed to
read_xml()
.
Value
For serialize
, NULL
unless connection = NULL
, when
the result is returned in a raw vector.
For unserialize
an R object.
Examples
library(xml2)
x <- read_xml("<a>
<b><c>123</c></b>
<b><c>456</c></b>
</a>")
b <- xml_find_all(x, "//b")
out <- xml_serialize(b, NULL)
xml_unserialize(out)
#> {xml_nodeset (2)}
#> [1] <b>\n <c>123</c>\n</b>
#> [2] <b>\n <c>456</c>\n</b>