Changeset 675 for trunk/src/xml2struct.m


Ignore:
Timestamp:
Aug 27, 2013, 11:25:21 PM (10 years ago)
Author:
sommeria
Message:

various bugs corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/xml2struct.m

    r663 r675  
    4848    case 'char'
    4949        out=ss; %reproduce the input string
    50         if ~strcmp(ss,'image')% bug with Matlab str2num('image')-> child face
     50        % try to convert to number if the char does not correspond to a function (otherwise str2num calls this function as it uses 'eval')
     51        if ~isempty(regexp(ss,'^(-*\d+\.*\d*\ *)+$')) || ~isempty(regexp(ss,'\d+e(-|+)\d+')) % if the string corresponds to a set of numbers (with possible sign and decimal, or scientific notation) separated by blanks
    5152            out=str2num(ss);
    52             %if isempty(regexp(ss,'^(-*\d+\.*\d*\ *)+$'))% if the string does not contain a set of numbers (with possible sign and decimal) separated by blanks
    53             if isempty(out)
    54                 sep_ind=regexp(ss,'\s&\s');% check for separator ' & ' which indicates column separation in tables
    55                 if ~isempty(sep_ind)
    56                     sep_ind=[-2 sep_ind length(ss)+1];
    57                     for icolumn=1:length(sep_ind)-1
    58                         out{1,icolumn}=ss(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1);
    59                     end
    60                 else
    61                     out=ss; %reproduce the input string
     53        else
     54            sep_ind=regexp(ss,'\s&\s');% check for separator ' & ' which indicates column separation in tables
     55            if ~isempty(sep_ind)
     56                sep_ind=[-2 sep_ind length(ss)+1];
     57                for icolumn=1:length(sep_ind)-1
     58                    out{1,icolumn}=ss(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1);
    6259                end
     60            else
     61                out=ss; %reproduce the input string
    6362            end
    6463        end
Note: See TracChangeset for help on using the changeset viewer.