Changeset 685 for trunk/src


Ignore:
Timestamp:
Sep 19, 2013, 10:37:44 AM (11 years ago)
Author:
sommeria
Message:

error message improved for reading xml files

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/imadoc2struct.m

    r675 r685  
    3535%% case of xml files
    3636if nargin ==1
    37     [s,Heading]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
     37    [s,Heading,errormsg]=xml2struct(ImaDoc);% convert the whole xml file in a structure s
    3838elseif nargin ==2
    39     [s,Heading]=xml2struct(ImaDoc,varargin{1});% convert the xml file in a structure s, keeping only the subtree defined in input
     39    [s,Heading,errormsg]=xml2struct(ImaDoc,varargin{1});% convert the xml file in a structure s, keeping only the subtree defined in input
    4040else %TODO: deal with more than two subtrees?
    41     [s,Heading]=xml2struct(ImaDoc,varargin{1},varargin{2});% convert the xml file in a structure s, keeping only the subtree defined in input
     41    [s,Heading,errormsg]=xml2struct(ImaDoc,varargin{1},varargin{2});% convert the xml file in a structure s, keeping only the subtree defined in input
     42end
     43if ~isempty(errormsg)
     44    errormsg=['imadoc2struct/xml2struct/' errormsg];
     45    return
    4246end
    4347if ~strcmp(Heading,'ImaDoc')
    44     errormsg='the input xml file is not ImaDoc';
     48    errormsg='imadoc2struct/the input xml file is not ImaDoc';
    4549    return
    4650end
  • trunk/src/xml2struct.m

    r675 r685  
    1010% varargin: optional list of strings to restrict the reading to a selection of subtrees, for instance 'GeometryCalib' (save time)
    1111
    12 function [s,Heading]=xml2struct(filename,varargin)
     12function [s,Heading,errormsg]=xml2struct(filename,varargin)
     13s=[];
     14Heading='';
     15errormsg='';
     16try
    1317t=xmltree(filename);
     18catch ME
     19    errormsg=ME.message;
     20    if regexp(ME.message,'xml_findstr')
     21        errormsg=[errormsg ': xmltree not correctly installed, download from www.artefact.tk/software/matlab/xml'];
     22    end
     23    return
     24end
    1425iline=0;
    15 Heading='';
     26
    1627while isempty(Heading)
    1728    iline=iline+1;
Note: See TracChangeset for help on using the changeset viewer.