Skip to contents

get_idml_contents() is a helper for extracting or converting xml_document objects from the idml list object.

Usage

get_idml_contents(
  idml,
  dir = NULL,
  file = NULL,
  format = "xml_document",
  ns = character(),
  parent_nm = NULL,
  unique_nm = TRUE,
  type = "attr",
  ...,
  error_call = caller_env()
)

format_idml_content(
  content,
  format = "xml_document",
  ns = character(),
  parent_nm = NULL,
  unique_nm = TRUE,
  type = "attr",
  names_to = zap(),
  allow_list = TRUE,
  ...,
  error_call = caller_env()
)

Arguments

idml

A idml class object created with read_idml().

dir, file

Directory and file name from IDML contents to return. If file is NULL,

format

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

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".

...

Needed for compatibility with generic. Unused.

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.

Value

A list, XML document, data frame, or data frame list depending on format and the input idml object.