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

John Clayton


Personal Profile:


Watch this Author's files


Comments and Ratings by John Clayton View all
Updated File Comments Rating
22 Dec 2011 xml_io_tools Read XML files into MATLAB struct and writes MATLAB data types to XML Author: Jaroslaw Tuszynski


Thanks for this excellent work. I enjoy using it, so I wanted to share what I did to possibly improve "xml_read".

Reading in the following .xml file:
<?xml version="1.0" encoding="utf-8"?>

I performed the following commands:
>> D3=xml_read('testrdsmall_jec.xml');
>> D3

D3 =

xtr_base: '0x30010'
reg_base: '0x30000'
pcm_base: {'0x30040' '0x30050'}

It bothered me that the resulting data structure in Matlab has both xtr_base and reg_base the same. I tried using Pref.CellItem=true, as in the following commands:

>> Pref.CellItem=true;
>> D2=xml_read('testrdsmall_jec.xml',Pref);
>> D2

D2 =

xtr_base: {'0x30010'}
reg_base: '0x30000'
pcm_base: {{1x2 cell}}

This did produce a difference between xtr_base and reg_base, but the pcm_base was now a cell-array within a cell-array! So, I decided to make a modification to your code...

So now, with my small modification, I do the following commands:

>> D5=xml_read_jec('testrdsmall_jec.xml');
>> D5

D5 =

xtr_base: {'0x30010'}
reg_base: '0x30000'
pcm_base: {'0x30040' '0x30050'}

It produces the result I expect. However, when I use Pref.CellItem=true, I get:

>> D=xml_read_jec('testrdsmall_jec.xml',Pref);
>> D

D =

xtr_base: {'0x30010'}
reg_base: '0x30000'
pcm_base: {{1x2 cell}}

... which is probably not exactly as it should be. So, maybe my modification is not entirely correct.

What I did was to change lines 383-387 from this:
if (isfield(s,Pref.ItemName))
s.CONTENT = s.(Pref.ItemName);
s = rmfield(s,Pref.ItemName);
ItemContent = Pref.CellItem; % if CellItem than keep s.CONTENT as cells

to be this instead:
if (isfield(s,Pref.ItemName))
% Check for singleton nodes that have the special keyword to mark arrays,
% and keep them as cell arrays, even though the resulting cell array
% only has one member. -- Modification by John Clayton, 12/22/11.
if ~iscell(s.(Pref.ItemName))
s.CONTENT = s.(Pref.ItemName);
s = rmfield(s,Pref.ItemName);
ItemContent = true;
s.CONTENT = s.(Pref.ItemName);
s = rmfield(s,Pref.ItemName);
ItemContent = Pref.CellItem; % if CellItem then keep s.CONTENT as cells

What do you think of this change? Perhaps I did it not very well, but I wanted to tell you about it.

Thanks again for your excellent work!

- John Clayton

07 Dec 2011 Specifying questdlg position ‘MFquestdlg’ enables you to specify the question dialog box location on the screen. Author: Saeid

This is exactly what I was looking for! Thanks so much, it was clearly described and worked well for me. I made one small modification - adding a new argument which allows loading an arbitrary image into the icon. If the image file is not found, then the standard icon is used. Once again, I appreciate this!

Contact us