Skip to contents

Get spreads from an IDML object

get_idml_spreads() extracts a list of xml documents for spreads or a data frame from a idml object.

Usage

get_idml_spreads(
  idml,
  format = "list",
  names_to = "Spread",
  ...,
  error_call = caller_env()
)

Arguments

idml

A idml class object created with read_idml().

format

"list", "xml_document", or "data.frame". If "list", contents are converted with xml2::as_list() using the supplied ns parameter.

names_to

By default, names(x) are lost. To keep them, supply a string to names_to and the names will be saved into a column with that name. If names_to is supplied and x is not named, the position of the elements will be used instead of the names.

...

Arguments passed on to get_idml_contents

ns

Optionally, a named vector giving prefix-url pairs, as produced by xml_ns(). If provided, all names will be explicitly qualified with the ns prefix, i.e. if the element bar is defined in namespace foo, it will be called foo:bar. (And similarly for attributes). Default namespaces must be given an explicit name. The ns is ignored when using xml_name<-() and xml_set_name().

parent_nm

Name of top-level parent node. If parent_nm is a character vector, extract_doc_df() returns a data frame list.

unique_nm

If TRUE, ensure that parent_node names are unique before using them to extract data from the xml_document. Ignored if node_names is supplied.

type

Type of data to extract from chlildren nodes: "attr" (attributes) or "text".

error_call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.