Code covered by the BSD License  

Highlights from
generateXML

Be the first to rate this file! 9 Downloads (last 30 days) File Size: 2.97 KB File ID: #6038
image thumbnail

generateXML

by Laurent Cavin

 

12 Oct 2004 (Updated 14 Oct 2004)

Output the input variable as an XML string suited for import in database systems.

| Watch this File

File Information
Description

xmlstr = generateXML(in)

Output the variable "in" as an XML string; intended for exporting structures for later import in a database.

It features the following specificities:

a) Cell-array and substructure linking:
Most database systems generate new tables for each substructure (or cell array, that are sort of structures also) present in the XML file (e.g. Access). Importing the XML results in several tables without relations...

With generateXML, when cell arrays or sub-structures are encountered, a "foreign key" is added in the parent object. The child cell array or structure recieve a corresponding "primary key". This allows keeping the relationships...

b) Blowing up the matrices:
Most database systems cannot import a matrix in one step. Each element is a single number, and in the best case, the whole matrix is imported as a long, space-separated string. With generateXML, matrices are devided into single elements, which each get a new label (e.g. mymatrix_1, mymatrix_2, ...). Thus matrices are correctly imported (with one value per column in the record).

This XML format generates a HUGE overhead, mostly because of the matrix blow-up, and is probably not usable when the structure contains very large matrices. It is however efficient for rather intrigate structures containing relatively small datasets. If you do not intend to import the data in a database, but only to save in human-readable form the data for further use in MATLAB or other custom software, it is advised to use the more efficient XML Toolbox by Marc Molinari, available on this website (link in Acknoledgements below). On top of it, generateXML is a one-way function and it does not feature an import fonctionality [yet]... to reimport data, or to work on the resulting database, use SQL and the CSE SQL Library, available on this website (link in Acknoledgements below).

The data types supported are: char, numeric (also complex), struct, cell, logical/boolean only. Sparse matrices are not supported.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
CSE SQL Database Library, XML Toolbox

MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Laurent Cavin 22 Oct 2008 07:33:00
data export Laurent Cavin 22 Oct 2008 07:33:00
xml Laurent Cavin 22 Oct 2008 07:33:00
export Laurent Cavin 22 Oct 2008 07:33:00
structure Laurent Cavin 22 Oct 2008 07:33:00
relationships Laurent Cavin 22 Oct 2008 07:33:00
xml Shucheng Dong 17 Dec 2009 03:24:19

Contact us at files@mathworks.com