Read XML files into MATLAB struct and writes MATLAB data types to XML
Updated 5 Nov 2010

View License

Read XML files into MATLAB struct and writes MATLAB data types to XML files, with help of simple interface to MATLAB's xmlwrite and xmlread functions.

Two function to simplify reading and writing XML files from MATLAB:

* Function xml_read first calls MATLAB's xmlread function and than converts its output ('Document Object Model' tree of Java objects) to tree of MATLAB struct's. The output is often in format of nested structs and cells. In the output data structure field names are based on XML tags.

* Function xml_write first convert input tree of MATLAB structs and cells and other types to tree of 'Document Object Model' nodes, and then writes resulting object to XML file using MATLAB's xmlwrite function.

This package can:
* Read any XML file, possibly created outside of MATLAB, and convert it to MATLAB data structures.
* Write any MATLAB's struct tree to XML file
* Handle XML attributes and special XML nodes like comments, processing instructions and CDATA sections
* Supports base64 encoding and decoding to allow handling embeded binary data
* Be studied, modified, customized, rewritten and used in other packages without any limitations. All code is included and documented. Software is distributed under BSD License (included).

This package can't:
* Guarantee to recover the same Matlab objects that were saved. If you need to be able to recover carbon copy of the structure that was saved than you will have to use one of the packages that uses special set of tags saved as xml attributes that help to guide the parsing of XML code. This package does not do that.
* Guarantee to work with MATLAB versions older than the package (2006/11). The code does not work with older versions of MATLAB.

Cite As

Jaroslaw Tuszynski (2024). xml_io_tools (https://www.mathworks.com/matlabcentral/fileexchange/12907-xml_io_tools), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: xunit4

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Fix problem with empty cells reported by Richard Cotton; fixed issues with reading boolean arrays reported by Zohar Bar-Yehuda; Improved speed of base64 coding and decoding by switching to java based code.