Description Usage Arguments Value Examples
View source: R/xml_replace_values.R
Replace values in a xml template document
1 | xml_replace_values(xml, replacement)
|
xml |
a xml document read with |
replacement |
one of a one row dataframe, a named list or a named vector where (col)names correspond to the values to replace in the xml template and the elements are the values to replace with |
a new xml document with changes applied to the xml template
1 2 3 4 5 | library(xml2)
template <- read_xml("<parent><child nom=\"child1\"><grandchild>grandchild1</grandchild>
<grandchild>grandchild2</grandchild></child><child nom=\"child2\">null</child></parent>")
toreplace <- c(child1 = "Ben", child2 = "Sarah", grandchild1 = "Brad", grandchild2 = "Jude")
newxml <- xml_replace_values(xml = template, replacement = toreplace)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.