Rank: 79677 based on 0 downloads (last 30 days) and 0 file submitted

Michael Murphy

Ford Motor Company

Personal Profile:
Professional Interests:


Watch this Author's files


Comments and Ratings by Michael
Updated File Comments Rating
30 Nov 2009 xml_io_tools Read XML files into MATLAB struct and writes MATLAB data types to XML Author: Jaroslaw Tuszynski

This is a great tool. It has greatly simplified my work.

However, I have discovered a small problem with xml_read(). The array of structures returned by xml_read() is organized differently depending on whether or not all structures have the same number of fields in the same order.

The code segment is
s(iItem).(field) = [x{:}];
if (Pref.NoCells)
s(iItem).(field) = forceCell2Struct(x);

This issue is that [x{:}] is equivalent to [x{1},x{2},...,x{n}] resulting in a [1xN] row vector. However, forceCell2Struct(x) uses the cell2struct() function which (for Matlab 7 R14 at least) results in a [Nx1] column vector.

The use of the cell2struct() function requires that the resulting output array must be arranged in a column. Accordingly, the above code segment is probably best "fixed" by transposing the row vector of the default array constructor into a column vector (e.g. = [x{:}]';).

Michael Murphy
Ford Motor Company

P.S. The xmlread() and xmlwrite() functions (for Matlab 7 R14 at least) cannot handle relative file specifications (i.e. ../file.xml) resulting in the ambiguous "Unable to parse XML file" error. To avoid this, the following code can be used to expand relative filepath specifications.

TERTIARY = @(expr,val1,val0) …
subsref( {val0,val1}, substruct( '{}', {1,1+sign(int32(expr))} ) );
ABS_PATH = @(file) …
strrep( fullfile( TERTIARY(strncmp(file,'.',1),pwd,''), file ), [filesep,'.',filesep], filesep );

[tree, root, node] = xml_read( ABS_PATH(filespec) );

Contact us