Changeset 675 for trunk/src/xml2struct.m
- Timestamp:
- Aug 27, 2013, 11:25:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/xml2struct.m
r663 r675 48 48 case 'char' 49 49 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 51 52 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); 62 59 end 60 else 61 out=ss; %reproduce the input string 63 62 end 64 63 end
Note: See TracChangeset
for help on using the changeset viewer.