source: trunk/src/xml2struct.m @ 339

Last change on this file since 339 was 324, checked in by gostiaux, 13 years ago

";" added

File size: 540 bytes
Line 
1function s=xml2struct(filename)
2% structure parser, converts numeric character strings into numbers
3
4t=xmltree(filename);
5ss=convert(t);
6s=convert_string(ss);
7
8
9function out=convert_string(s)
10info=whos('s');
11switch info.class
12    case 'struct'
13        names = fieldnames(s);
14        for k=1:length(names)
15            out.(names{k})=convert_string(s.(names{k}));
16        end
17    case 'char'
18        if isempty(regexp(s,'\<\d+\>'))
19            out=s;
20        else
21            out=str2num(s);
22        end
23    otherwise
24        out=s;
25end
26
27   
Note: See TracBrowser for help on using the repository browser.