Changeset 821 for trunk/src/@xmltree/xmltree.m
- Timestamp:
- Oct 8, 2014, 9:10:00 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/@xmltree/xmltree.m
r723 r821 3 3 % FORMAT tree = xmltree(varargin) 4 4 % 5 % filename - XML filename5 % varargin - XML filename or XML string 6 6 % tree - XMLTree Object 7 7 % 8 % tree = xmltree; % creates a minimal XML tree: <tag/> 9 % tree = xmltree(filename); % creates a tree from an XML file 8 % tree = xmltree; % creates a minimal XML tree: '<tag/>' 9 % tree = xmltree('foo.xml'); % creates a tree from XML file 'foo.xml' 10 % tree = xmltree('<tag>content</tag>') % creates a tree from string 10 11 %_______________________________________________________________________ 11 12 % … … 32 33 tree = varargin{1}; 33 34 elseif ischar(varargin{1}) 34 tree.tree = xml_parser(varargin{1}); 35 tree.filename = varargin{1}; 35 % Input argument is an XML string 36 if (exist(varargin{1}) ~= 2 & ... 37 ~isempty(xml_findstr(varargin{1},'<',1,1))) 38 tree.tree = xml_parser(varargin{1}); 39 tree.filename = ''; 40 % Input argument is an XML filename 41 else 42 fid = fopen(varargin{1},'rt'); 43 if (fid == -1) 44 error(['[XMLTree] Cannot open ' varargin{1}]); 45 end 46 xmlstr = fscanf(fid,'%c'); 47 fclose(fid); 48 tree.tree = xml_parser(xmlstr); 49 tree.filename = varargin{1}; 50 end 36 51 tree = class(tree,'xmltree'); 37 52 else … … 39 54 end 40 55 otherwise 41 error('[XMLTree] Bad number ofarguments');56 error('[XMLTree] Too many input arguments'); 42 57 end
Note: See TracChangeset
for help on using the changeset viewer.