xml_to_list {xmlconvert} | R Documentation |
Converting XML documents to lists
Description
Converts XML documents to lists. Uses the
as_list()
function from the
xml2
package but improves its output. As an effect, numbers, dates
and times are converted correctly, unnecessary nested sub-lists with only
element are avoided, and empty XML nodes can be removed altogether. This
makes the resulting list look cleaner and better structured.
Usage
xml_to_list(
xml,
cleanup = TRUE,
convert.types = TRUE,
dec = ".",
thsd = ",",
num.replace = "",
datetime.formats = NULL
)
Arguments
xml |
XML document to be converted. Can be read in from a file using
|
cleanup |
If |
convert.types |
If |
dec |
Decimal separator used in numbers. |
thsd |
Thousands separator used in numbers. |
num.replace |
An optional string that will be removed before
|
datetime.formats |
A vector of date and/or time formats that will be
used to recognize the respective datatypes. Formats will need to be written
in the general notation used by |
Value
A list
object representing the XML document.
Examples
xml <- xml2::read_xml(system.file("customers.xml", package="xmlconvert"))
xml.list <- xml_to_list(xml, num.replace="USD", datetime.formats = "%Y-%m-%d")#'