xml_doc: Create an xml_fragment with a root element, (kind of tag)

View source: R/xml_fragment.R

xml_docR Documentation

Create an xml_fragment with a root element, (kind of tag)

Description

Create an xml_fragment with a root element, (kind of tag)

Usage

xml_doc(root, ..., .attr = list(...))

Arguments

root

the name of the root element

...

additional attributes to add to the tag

.attr

a list of additional attributes to add to the tag, overrides the ... argument

Value

an xml_fragment with the root element

Examples


tag("greeting", "hi", id = "hi")

tag("person", id = "1") / (tag("name", "John Doe") + tag("age", 35))

xml_fragment(person = frag(
  .attr = c(id = 1),
  name = "John Doe",
  age = 30
))   / tag("address", "Unknown")


a <- tag("person", id = 1) /
  xml_fragment(
    name ="John Doe",
    age = 30,
    address = frag(
      street = "123 Main St",
      city = "Springfield"
    )
  )

cat(as.character(a))

xmlwriter documentation built on Sept. 25, 2024, 5:06 p.m.