This function converts XML files created using LabVIEW™ software into MATLAB® structure arrays.
Updated 1 Jul 2019

View License

This function converts XML files which have been created using the "Flatten To XML" and "Write to XML File" VIs into structure arrays, using the names of controls/variables as field names in the structure. It supports reading clusters, arrays, boolean values, timestamps, enums, integers, fixed-point numbers, floating point numbers, strings, rings, analog waveforms and variant data. Clusters and arrays can contain any of the supported types in any combination. Error clusters are clusters with three named elements so they are supported, too.

All variables need to have names, except array elements. If a variable does not have a name the function exits with an error. Variable names need to be unique at their level of nesting (i.e. names of elements in a cluster must be unique). Variable names are converted to legal structure field names (see createLegalStructFieldName function).

Integers are imported in their correct type, i.e. a control of type I8/I16/I32/I64/U8/U16/U32/U64 is imported as int8/int16/int32/int64/uint8/uint16/uint32/uint64.

Floating-point numbers are imported as double precision floats if possible. This is the case for both real and complex single and double precision floating point numbers. Extended precision real and complex floating-point numbers are imported as strings because there is no numeric equivalent in MATLAB®. Fixed-point numbers are imported as a structure which contains word and integer length as doubles, the signed flag as logical, value, minimum and maximum as structs containing a negative flag as logical and the value as a uint64 (independend of the negative flag value). The fixed-point struct contains another struct in the field "Delta" which contains word length, integer length and value as above. Overflow status is not exported by the "Flatten To XML" VI and therefore cannot be imported.

Boolean values are imported as logicals.

Timestamps are converted to datetime structures with TimeZone set to UTC. Please note that during this conversion precision is lost because the datetime structure cannot resolve the attosecond precision of LabVIEW™ timestamps.

Text/menu rings are imported as their representation since the "Flatten To XML" VI does not include the Item value in the XML file.

Enums are imported as a string containing the selected item.

LvVariant entries are essentially just containers of other data structures, so they are imported as a structure array containing these other data structures. Please note that the "Flatten To XML" VI does not include variant attributes, so they are not imported.

Clusters are imported as structs containing their elements as fields with the element name being the field name.

Arrays are imported as either cell or ordinary array, depending on the type of elements the array contains: Single and double precision real and complex floating point numbers, all integer types and logicals are converted to ordinary arrays. All numbers of dimensions are supported. Arrays can contain all other supported data types.

Strings are imported as a character array if the string is a single line or as a cell array (column vector) of character arrays if the string has multiple lines.

Paths are handled as strings.

Analog waveforms are essentially clusters and are imported as such. They contain a timestamp in field "t0", a double precision floating point number in the field "dt", an array named "Y", an error cluster in the field "error" and an LvVariant named "attributes". All possible data types of the "Y" array elements are supported.

Digital waveforms are not supported. Feel free to add this functionality!

For now, the XML file must start with the two lines
<?xml version='1.0' standalone='yes' ?>
<LVData xmlns="">
followed by a <Version> tag and end with the line
These lines are created by the "Write to XML File" VI.

Example XML files and VIs are still missing.

This function is MUCH faster than using the xmlread function!


Tested with LabVIEW™ software version 12.0.1f5, 15.0 and MATLAB® version R2016a/9.0, R2017b/9.3.

MATLAB is a registered trademark of The MathWorks, Inc., LabVIEW is a trademark of National Instruments.

Copyright 2019, Tilman Raphael Schröder <>

Cite As

Max Mustermann (2024). parseLabviewXML (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017b
Compatible with R2010b and later releases
Platform Compatibility
Windows macOS Linux
Find more on LabVIEW in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Multiple top level blocks now supported (you can concatenate the output of multiple "Flatten To XML" VIs now).
Added assert messages.

File handle is now properly closed even on errors.

Added support for Labview Variants
Structure field names are now created using matlab.lang.makeValidName
Dropped GPLv2

Added support for multiline strings, paths, all analog waveform types, all floating point types, fixed import of empty arrays. Added documentation. Some code cleanup.

Proper title.

Inserted trademark comment into title, summary and description.