xml2relational {xml2relational} | R Documentation |
Package 'xml2relational'
Description
Transforming a hierarchical XML document into a relational data model.
What is xml2relational
The xml2relational
package is
designed to 'flatten' XML documents with nested objects into relational
dataframes. xml2relational
takes an XML file as input and converts
it into a set of dataframes (tables). The tables are linked among each
other with foreign keys and can be exported as CSV or ready-to-use SQL code
(CREATE TABLE
for the data model, INSERT INTO
for the data).
How to use xml2relational
First, use
toRelational()
to read in an XML file and to convert into a relational data model.This will give you a list of dataframes, one for each table in the relational data model. Tables are linked by foreign keys. You can specify the naming convention for the tables' primary and foreign keys as arguments in
toRelational()
.You can now export the data structures of the tables (or a selection of tables) using
getCreateSQL()
. It support multiple SQL dialects, and you also provide syntax and data type information for additional SQL dialects.You can also export the data as SQL
INSERT
statements with thegetInsertSQL()
. If you only want to export the data as CSV usesavetofiles()
to save the dataframes produced bytoRelational()
as comma-separated files.