Code covered by the BSD License  

Highlights from
Use Mac OS X XML Plists with MATLAB (Updated Version)

Use Mac OS X XML Plists with MATLAB (Updated Version)

by

 

A updated version of that by John Iversen

saveXMLPlist(fname, S,KT)
function S = saveXMLPlist(fname, S,KT)
% saveXMLPlist  Save structure as Mac OSX XML property list
%
%   saveXMLPlist(filename, S)
%
%       Convert S into property list and save to filename
%
%   See structToXMLPlist.m for details.
%
%   JRI 3/16/05 (John R. Iversen <iversen@nsi.edu>)

%KT keyname table


text = structToXMLPlist(S);



if nargin>2
    
    TF = strcmp(KT(:,1),KT(:,2));
    df=find(~TF);
    for k=df'
        str1 =['>' KT{k,1} '<'];% original name in plist file
        str2 = ['>' KT{k,2} '<'];% field name, 
%         fprintf('%d: %s \t %s \n',k,str2,str1);
%         str2
%         text = regexprep(text,str2,str1);
        text = strrep(text,str2,str1);

    end
end


fid = fopen(fname, 'w');
fprintf(fid, '%s', text);
fclose(fid);

Contact us