append.xmlNode | R Documentation |
This appends one or more XML nodes as children of an existing node.
append.XMLNode(to, ...)
append.xmlNode(to, ...)
to |
the XML node to which the sub-nodes are to be added. |
... |
the sub-nodes which are to be added to the |
append.xmlNode
is a generic function with method append.XMLNode
for class "XMLNode"
and default method base::append
.
This seems historical and users may as well use append.XMLNode
directly.
The original to
node containing its new children nodes.
Duncan Temple Lang
https://www.w3.org/XML/, http://www.jclark.com/xml/, https://www.omegahat.net
[<-.XMLNode
[[<-.XMLNode
[.XMLNode
[[.XMLNode
# Create a very simple representation of a simple dataset.
# This is just an example. The result is
# <data numVars="2" numRecords="3">
# <varNames>
# <string>
# A
# </string>
# <string>
# B
# </string>
# </varNames>
# <record>
# 1.2 3.5
# </record>
# <record>
# 20.2 13.9
# </record>
# <record>
# 10.1 5.67
# </record>
# </data>
n = xmlNode("data", attrs = c("numVars" = 2, numRecords = 3))
n = append.xmlNode(n, xmlNode("varNames", xmlNode("string", "A"), xmlNode("string", "B")))
n = append.xmlNode(n, xmlNode("record", "1.2 3.5"))
n = append.xmlNode(n, xmlNode("record", "20.2 13.9"))
n = append.xmlNode(n, xmlNode("record", "10.1 5.67"))
print(n)
## Not run:
tmp <- lapply(references, function(i) {
if(!inherits(i, "XMLNode"))
i <- xmlNode("reference", i)
i
})
r <- xmlNode("references")
r[["references"]] <- append.xmlNode(r[["references"]], tmp)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.