Changeset 560 for trunk/src/xml2struct.m


Ignore:
Timestamp:
Nov 21, 2012, 12:48:54 PM (12 years ago)
Author:
sommeria
Message:

imadoc2struct corrected with the use of the more general function xml2struct. This allows to get all the content of the xml file in XmlData?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/xml2struct.m

    r477 r560  
    88% INPUT:
    99% filename: name of the xml file
     10% varargin: optional list of strings to restrict the reading to a selection of subtrees, for instance 'GeometryCalib' (save time)
    1011
    11 function [s,Heading]=xml2struct(filename)
     12function [s,Heading]=xml2struct(filename,varargin)
    1213t=xmltree(filename);
    1314Heading=get(t,1,'name');
    14 ss=convert(t);
    15 s=convert_string(ss);
     15if nargin>1
     16    for isub=1:nargin-1
     17        uid_sub=find(t,['/' Heading '/' varargin{isub}]);
     18        tsub=branch(t,uid_sub);
     19        ss=convert(tsub);
     20        s.(varargin{isub})=convert_string(ss);
     21    end
     22else
     23    ss=convert(t);
     24    s=convert_string(ss);
     25end
    1626
    1727
Note: See TracChangeset for help on using the changeset viewer.