xmlFromList: Creat an XML Node from a list

Description Usage Arguments Value Author(s) Examples

View source: R/utils.xmlWrite.R

Description

This function appends a list as an XML object to an item. The function allows setting attributes of XML items by using the "attributes" list name, therefore it can never write tags with the name "attributes"

Usage

1
xmlFromList(node, sublist)

Arguments

node

(XMLNode) A Node created by XML package

sublist

(list) Any list

Value

node (XMLNode) A node where the list is attached to the first XML Node

Author(s)

Sebastian Wolf sebastian.wolf.sw1@roche.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
root <- XML::newXMLNode("root")
li <- list(a = list(aa = 1, ab=2),
      b=list(ba = 1,
                bb=list(x=4,
                       attributes=c(value=3)),
               bb= 2,
              bc =3))
xmlFromList(root,li)

# The result is an XML Node like this
#<root>
#  <a>
#    <aa>1</aa>
#    <ab>2</ab>
#  </a>
#  <b>
#    <ba>1</ba>
#    <bb value="3">
#      <x>4</x>
#    </bb>
#    <bb>2</bb>
#    <bc>3</bc>
#  </b>
#</root>

RTest documentation built on Dec. 4, 2019, 5:07 p.m.