as_xml_document: Coerce a R list to xml nodes.

Description Usage Arguments Examples

View source: R/as_xml_document.R

Description

This turns an R list into the equivalent XML document. Not all R lists will produce valid XML, in particular there can only be one root node and all child nodes need to be named (or empty) lists. R attributes become XML attributes and R names become XML node names.

Usage

1

Arguments

x

A document, node, or node set.

...

Needed for compatibility with generic. Unused.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
as_xml_document(list(x = list()))

# Nesting multiple nodes
as_xml_document(list(foo = list(bar = list(baz = list()))))

# attributes are stored as R attributes
as_xml_document(list(foo = structure(list(), id = "a")))
as_xml_document(list(foo = list(
     bar = structure(list(), id = "a"),
     bar = structure(list(), id = "b"))))

Example output

{xml_document}
<x>
{xml_document}
<foo>
[1] <bar>\n  <baz/>\n</bar>
{xml_document}
<foo id="a">
{xml_document}
<foo>
[1] <bar id="a"/>
[2] <bar id="b"/>

xml2 documentation built on Jan. 24, 2018, 5:21 p.m.