Description Usage Arguments Value Examples
View source: R/xml_fill_tempate.R
Title
1 2 |
xmltemplate |
a xml document to use as template |
with |
a dataframe with the values of elements to replace in |
collapse |
if |
export |
a string giving the path to the folder where the xml files are exported. If |
name |
optional. Only if |
either a list of length nrow(with)
where each element is a new xml document or only one new xml document if collapse!=NULL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(xml2)
template <- read_xml("<parent><child nom=\"child1\"><grandchild>grandchild1</grandchild>
<grandchild>grandchild2</grandchild></child><child nom=\"child2\">null</child></parent>")
toreplace <- data.frame(child1 = c("Ben1", "Ben2"), child2 = c("Sarah1", "Sarah2"),
grandchild1 = c("Brad1", "Brad2"), grandchild2 = c("Jude1", "jude2"))
# No export, no collapsing
newxml <- xml_fill_template(template, toreplace)
# Export and collapsing
## Not run:
newxml <- xml_fill_template(template, toreplace, collapse = "grandparent",
export = getwd(), name = "testexport")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.