Learn R Programming

openxlsx2 (version 0.4.1)

xml_attr_mod: adds or updates attribute(s) in existing xml node

Description

Needs xml node and named character vector as input. Modifies the arguments of each first child found in the xml node and adds or updates the attribute vector.

Usage

xml_attr_mod(xml_content, xml_attributes, escapes = FALSE, declaration = FALSE)

Arguments

xml_content

some valid xml_node

xml_attributes

R vector of named attributes

escapes

bool if escapes should be used

declaration

bool if declaration should be imported

Details

If a named attribute in xml_attributes is "" remove the attribute from the node. If xml_attributes contains a named entry found in the xml node, it is updated else it is added as attribute.

Examples

Run this code
  # add single node
    xml_node <- "openxlsx2"
    xml_attr <- c(qux = "quux")
    # "openxlsx2"
    xml_attr_mod(xml_node, xml_attr)

  # update node and add node
    xml_node <- "openxlsx2"
    xml_attr <- c(foo = "baz", qux = "quux")
    # "openxlsx2"
    xml_attr_mod(xml_node, xml_attr)

  # remove node and add node
    xml_node <- "openxlsx2"
    xml_attr <- c(foo = "", qux = "quux")
    # "openxlsx2"
    xml_attr_mod(xml_node, xml_attr)

Run the code above in your browser using DataLab