Ignore:
Timestamp:
Feb 6, 2026, 5:13:05 PM (2 weeks ago)
Author:
sommeria
Message:

bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/xml2struct.m

    r1183 r1191  
    3939catch ME
    4040    errormsg=ME.message;
    41     if ~isempty(regexp(ME.message,'Undefined function','once'))||~isempty(regexp(ME.message,'Missing','once'))
     41    if ~isempty(regexp(ME.message,'Undefined function'))||~isempty(regexp(ME.message,'Missing'))
    4242        errormsg=[errormsg ': package xmltree not correctly installed, reload it from www.artefact.tk/software/matlab/xml'];
    4343    end
     
    5252    end
    5353end
    54 if nargin>1 % additional input vartiable(s) beyond filename, select specified subtrees
     54if nargin>1
    5555    for isub=1:nargin-1
    5656        uid_sub=find(t,['/' RootTag '/' varargin{isub}]);
     
    5858            s.(varargin{isub})=[];
    5959        else
    60             tsub=branch(t,uid_sub);
    61             if ~isempty(get(tsub,1,'contents'))
    62                 ss=convert(tsub);
    63                 s.(varargin{isub})=convert_string(ss);
    64             end
     60        tsub=branch(t,uid_sub);
     61        if ~isempty(get(tsub,1,'contents'))
     62        ss=convert(tsub);
     63        s.(varargin{isub})=convert_string(ss);
     64        end
    6565        end
    6666    end
    6767else
    6868    try
    69         ss=convert(t);%transform the xmltree object into a Matlab structure.
    70         s=convert_string(ss);% explore the sub-structures if needed
     69    ss=convert(t);%transform the xmltree object into a Matlab structure.
     70    s=convert_string(ss);
    7171    catch ME
    7272        errormsg=ME.message;
     
    8585        end
    8686    case 'char'
    87         % try to convert to number if the char does not correspond to a function (otherwise str2num calls this function as it uses 'eval')
    88         if exist(ss,'builtin')||exist(ss,'file')% ss corresponds to the name of a builtin Matlab function or a file
    89             out=ss; %reproduce the input string
    90         else
    91             out=str2num(ss);% convert to number or vector (str2num applied to a fct name executes this fct by 'eval', thus this possibility had to be ruled out above
    92             if isempty(out)
     87            out=str2double(strsplit(ss));% convert to number or vector (str2num applied to a fct name executes this fct by 'eval', thus this possibility had to be ruled out above
     88            if isnan(out)
    9389                sep_ind=regexp(ss,'\s&\s');% check for separator ' & ' which indicates column separation in tables
    9490                if ~isempty(sep_ind)
     
    10298                end
    10399            end
    104          end
    105100    case 'cell'
    106         out={};%default
     101        out=cell(numel(ss),1);%default
    107102        check_numeric=zeros(size(ss));
    108103        for ilist=1:numel(ss)
    109             if ~strcmp(ss{ilist},'image') && ~isempty(str2num(ss{ilist}))
    110                 out{ilist,1}=str2num(ss{ilist});
     104            if  ~isnan(str2double(strsplit(ss{ilist})))
     105                out{ilist,1}=str2double(strsplit(ss{ilist}));
    111106                check_numeric(ilist)=1;
    112107            else
     
    129124end
    130125
     126
    131127   
Note: See TracChangeset for help on using the changeset viewer.