Index: /trunk/src/@xmltree/Contents.m
===================================================================
--- /trunk/src/@xmltree/Contents.m	(revision 723)
+++ /trunk/src/@xmltree/Contents.m	(revision 723)
@@ -0,0 +1,46 @@
+% XMLTree: XML Toolbox for Matlab.
+% Version 1.0  12-Apr-2002
+%
+% XML file I/O.
+%   xmltree     - Constructor (XML parser).
+%   save        - Save an XMLTree in a file.
+%
+% XML Tree manipulation methods.
+%   add         - Add a node in a tree.
+%   attributes  - Handle attributes of a node.
+%   branch      - Extract a subtree from a tree.
+%   children    - Return children of a node.
+%   convert     - Convert a tree in a Matlab structure.
+%   copy        - Copy nodes within a tree.
+%   delete      - Delete a node in a tree.
+%   find        - Find nodes in a tree.
+%   flush       - Clear a subtree.
+%   get         - get node properties.
+%   getfilename - Get filename.
+%   isfield     - Return true if a field is present in a node.
+%   length      - Return the length of a tree.
+%   move        - Move a node within a tree.
+%   parent      - Return parents of a node.
+%   root        - Return the root element of a tree.
+%   set         - Set node properties.
+%   setfilename - Set filename
+%
+% Graphical user interface methods (work in progress).
+%   view        - Graphical display of a tree.
+%   view_ui     - Useful function for view method.
+%
+% Low level class methods.
+%   char        - Convert a tree into a string (for display).
+%   display     - Display a tree into MATLAB.
+%
+% Private methods.
+%   xml_parser  - XML parser.
+%   xml_findstr - Find one string within another (mexfile)
+%
+% Demos.
+%   xmldemo1    - Create an XML tree from scratch and save it.
+%   xmldemo2    - Read an XML file and access fields.
+%   xmldemo3    - Read an XML file, modify some fields and save it.
+
+% Copyright 2002 Guillaume Flandin - INRIA Sophia Antipolis
+% $Revision: 1.0 $
Index: /trunk/src/@xmltree/add.m
===================================================================
--- /trunk/src/@xmltree/add.m	(revision 723)
+++ /trunk/src/@xmltree/add.m	(revision 723)
@@ -0,0 +1,92 @@
+function varargout = add(tree,uid,type,parameter)
+% XMLTREE/ADD Method (add childs to elements of an XML Tree)
+% FORMAT vararout = add(tree,uid,type,parameter)
+% 
+% tree      - XMLTree object
+% uid       - array of uid's
+% type      - 'element', 'chardata', 'cdata', 'pi' or 'comment'
+% parameter - property name (a character array unless type='pi' for
+%             which parameter=struct('target','','value',''))
+%
+% new_uid   - UID's of the newly created nodes
+%
+%        tree = add(tree,uid,type,parameter);
+%        [tree, new_uid] = add(tree,uid,type,parameter);
+%_______________________________________________________________________
+%
+% Add a node (element, chardata, cdata, pi or comment) in the XML Tree.
+% It adds a child to the element whose UID is iud.
+% Use attributes({'set','get','add','del','length'},...) function to 
+% deal with the attributes of an element node (initialized empty).
+% The tree parameter must be in input AND in output.
+%_______________________________________________________________________
+% @(#)add.m                   Guillaume Flandin                02/03/29
+
+error(nargchk(4,4,nargin));
+
+if ~isa(uid,'double')
+	error('[XMLTree] UID must be a double array.');
+end
+if ~ischar(type)
+	error('[XMLTree] TYPE must be a valid item type.');
+end
+if strcmp(type,'pi')
+	if ~isfield(parameter,'target') | ~isfield(parameter,'value') | ...
+	   ~ischar(parameter.target) | ~ischar(parameter.value)
+		error('[XMLTree] For a Processing Instruction, ',...
+						'PARAMETER must be a struct.');
+	end
+elseif ~ischar(parameter)
+	error('[XMLTree] PARAMETER must be a string.');
+end
+
+if nargout == 2
+	l = length(tree.tree);
+	varargout{2} = (l+1):(l+prod(size(uid)));
+end
+
+for i=1:prod(size(uid))
+	if uid(i)<1 | uid(i)>length(tree.tree)
+		error('[XMLTree] Invalid UID.');
+	end
+	if ~strcmp(tree.tree{uid(i)}.type,'element')
+		error('[XMLTree] Cannot add a child to a non-element node.');
+	end
+	l = length(tree.tree);
+	switch type
+		case 'element'
+			tree.tree{l+1} = struct('type','element',...
+        	                        'name',parameter,...
+					                'attributes',[],...
+					                'contents',[],...
+									'parent',[],...
+					                'uid',l+1);
+		case 'chardata'
+			tree.tree{l+1} = struct('type','chardata',...
+					                'value',parameter,...
+									'parent',[],...
+					                'uid',l+1);
+		case  'cdata'
+			tree.tree{l+1} = struct('type','cdata',...
+					                'value',parameter,...
+									'parent',[],...
+					                'uid',l+1);
+		case 'pi'
+			tree.tree{l+1} = struct('type','pi',...
+									'target',parameter.target,...
+					                'value',parameter.value,...
+									'parent',[],...
+					                'uid',l+1);
+		case 'comment'
+			tree.tree{l+1} = struct('type','comment',...
+					                'value',parameter,...
+									'parent',[],...
+					                'uid',l+1);
+		otherwise
+			error(sprintf('[XMLTree] %s: unknown item type.',type));
+	end
+	tree.tree{uid(i)}.contents = [tree.tree{uid(i)}.contents l+1];
+	tree.tree{l+1}.parent = uid(i);
+end
+
+varargout{1} = tree;
Index: /trunk/src/@xmltree/attributes.m
===================================================================
--- /trunk/src/@xmltree/attributes.m	(revision 723)
+++ /trunk/src/@xmltree/attributes.m	(revision 723)
@@ -0,0 +1,103 @@
+function varargout = attributes(varargin)
+% XMLTREE/ATTRIBUTES Method (handle attributes of an element node)
+% FORMAT varargout = attributes(varargin)
+% 
+% tree    - XMLTree object
+% method  - 'set','get','add','del' or 'length'
+% uid     - the UID of an element node
+% n       - indice of the attribute
+% key     - string key="..."
+% val     - string ...="val"
+% attr    - cell array of struct(key,val) or just struct(key,val)
+% l       - number of attributes of the element node uid
+%
+%     tree = attributes(tree,'set',uid,n,key,val)
+% 	  attr = attributes(tree,'get',uid[,n])
+% 	  tree = attributes(tree,'add',uid,key,val)
+% 	  tree = attributes(tree,'del',uid[,n])
+% 	  l    = attributes(tree,'length',uid)
+%_______________________________________________________________________
+%
+% Handle attributes of an element node.
+% The tree parameter must be in input AND in output for 'set', 'add' and
+% 'del' methods.
+%_______________________________________________________________________
+% @(#)attributes.m               Guillaume Flandin             02/04/05
+
+error(nargchk(3,6,nargin));
+tree = varargin{1};
+if ~ischar(varargin{2}) | ...
+   ~any(strcmp(varargin{2},{'set','get','add','del','length'}))
+	error('[XMLTree] Unknown method.');
+end
+uid = varargin{3};
+if ~isa(uid,'double') | any(uid>length(tree)) | any(uid<1)
+	error('[XMLTree] UID must be a positive integer scalar.');
+end
+
+if ~strcmp(tree.tree{uid}.type,'element')
+	error('[XMLTree] This node has no attributes.');
+end
+
+switch varargin{2}
+	case 'set'
+		error(nargchk(6,6,nargin));
+		if ~isa(varargin{4},'double') | ...
+		   any(varargin{4}>length(tree.tree{uid}.attributes)) | ...
+		   any(varargin{4}<1)
+			error('[XMLTree] Invalid attribute indice.');
+		end
+		ind = varargin{4};
+		tree.tree{uid}.attributes{ind} = struct('key',varargin{5},'val',varargin{6});
+		varargout{1} = tree;
+	case 'get'
+		error(nargchk(3,4,nargin));
+		if nargin == 4
+			if ~isa(varargin{4},'double') | ...
+			   any(varargin{4}>length(tree.tree{uid}.attributes)) | ...
+			   any(varargin{4}<1)
+				error('[XMLTree] Invalid attribute indice.');
+			end
+			if length(varargin{4}) == 1
+				varargout{1} = tree.tree{uid}.attributes{varargin{4}(1)};
+			else
+				varargout{1} = {};
+				for i=1:length(varargin{4})
+					varargout{1}{i} = tree.tree{uid}.attributes{varargin{4}(i)};
+				end
+			end
+		else
+			if length(tree.tree{uid}.attributes) == 1
+				varargout{1} = tree.tree{uid}.attributes{1};
+			else
+				varargout{1} = {};
+				for i=1:length(tree.tree{uid}.attributes)
+					varargout{1}{i} = tree.tree{uid}.attributes{i};
+				end
+			end
+		end
+	case 'add'
+		error(nargchk(5,5,nargin));
+		ind = length(tree.tree{uid}.attributes) + 1;
+		tree.tree{uid}.attributes{ind} = struct('key',varargin{4},'val',varargin{5});
+		varargout{1} = tree;
+	case 'del'
+		error(nargchk(3,4,nargin));
+		if nargin == 4
+			if ~isa(varargin{4},'double') | ...
+		      any(varargin{4}>length(tree.tree{uid}.attributes)) | ...
+		      any(varargin{4}<1)
+				error('[XMLTree] Invalid attribute indice.');
+			end
+			ind = varargin{4};
+			tree.tree{uid}.attributes(ind) = [];
+		else
+			tree.tree{uid}.attributes = [];
+		end
+		varargout{1} = tree;
+	case 'length'
+		error(nargchk(3,3,nargin));
+		varargout{1} = length(tree.tree{uid}.attributes);
+	otherwise
+		error('[XMLTree] Unknown method.');
+end
Index: /trunk/src/@xmltree/branch.m
===================================================================
--- /trunk/src/@xmltree/branch.m	(revision 723)
+++ /trunk/src/@xmltree/branch.m	(revision 723)
@@ -0,0 +1,49 @@
+function subtree = branch(tree,uid)
+% XMLTREE/BRANCH Branch Method
+% FORMAT uid = parent(tree,uid)
+% 
+% tree    - XMLTree object
+% uid     - UID of the root element of the subtree
+% subtree - XMLTree object (a subtree from tree)
+%_______________________________________________________________________
+%
+% Return a subtree from a tree.
+%_______________________________________________________________________
+% @(#)branch.m                  Guillaume Flandin              02/04/17
+
+error(nargchk(2,2,nargin));
+
+if uid > length(tree) | ...
+   prod(size(uid))~=1 | ...
+   ~strcmp(tree.tree{uid}.type,'element')
+	error('[XMLTree] Invalid UID.');
+end
+
+subtree = xmltree;
+subtree = set(subtree,root(subtree),'name',tree.tree{uid}.name);
+
+child = children(tree,uid);
+
+for i=1:length(child)
+	l = length(subtree);
+	subtree = sub_branch(tree,subtree,child(i),root(subtree));
+	subtree.tree{root(subtree)}.contents = [subtree.tree{root(subtree)}.contents l+1];
+end
+
+%=======================================================================
+function tree = sub_branch(t,tree,uid,p)
+
+	l = length(tree);
+	tree.tree{l+1} = t.tree{uid};
+	tree.tree{l+1}.uid = l + 1;
+	tree.tree{l+1}.parent = p;
+	tree.tree{l+1}.contents = [];
+	if isfield(t.tree{uid},'contents')
+		contents = get(t,uid,'contents');
+		m = length(tree);
+		for i=1:length(contents)
+			tree.tree{l+1}.contents = [tree.tree{l+1}.contents m+1];
+			tree = sub_branch(t,tree,contents(i),l+1);
+			m = length(tree);
+		end
+	end
Index: /trunk/src/@xmltree/char.m
===================================================================
--- /trunk/src/@xmltree/char.m	(revision 723)
+++ /trunk/src/@xmltree/char.m	(revision 723)
@@ -0,0 +1,14 @@
+function s = char(tree)
+% XMLTREE/CHAR Converter function from XMLTree to a description string
+% FORMAT s = char(tree)
+%
+% tree - XMLTree object
+% s    - a description string of an XMLTree
+%_______________________________________________________________________
+%
+% Return a string describing the XMLTree:
+%               'XMLTree object (x nodes) [filename]'
+%_______________________________________________________________________
+% @(#)char.m                   Guillaume Flandin               02/04/04
+
+s = strcat('XMLTree object (',num2str(length(tree)),' nodes) [',getfilename(tree),']');
Index: /trunk/src/@xmltree/children.m
===================================================================
--- /trunk/src/@xmltree/children.m	(revision 723)
+++ /trunk/src/@xmltree/children.m	(revision 723)
@@ -0,0 +1,28 @@
+function child = children(tree,uid)
+% XMLTREE/CHILDREN Return children's UIDs of node uid
+% FORMAT child = children(tree,uid)
+%
+% tree   - a tree
+% uid    - uid of the element
+% child  - array of the UIDs of children of node uid
+%_______________________________________________________________________
+%
+% Return UID's of children of node uid
+%_______________________________________________________________________
+% @(#)children.m              Guillaume Flandin                02/04/09
+
+error(nargchk(2,2,nargin));
+
+child = [];
+uid = uid(:);
+l = length(tree);
+for i=1:length(uid)
+	if uid(i) > 0 & uid(i) <= l
+		if strcmp(tree.tree{uid(i)}.type,'element')
+			child = [child tree.tree{uid(i)}.contents];
+		end
+	else
+		error('[XMLTree] Invalid UID.');
+	end
+end
+if isempty(child), child = []; end
Index: /trunk/src/@xmltree/convert.m
===================================================================
--- /trunk/src/@xmltree/convert.m	(revision 723)
+++ /trunk/src/@xmltree/convert.m	(revision 723)
@@ -0,0 +1,130 @@
+function s = convert(tree,uid)
+% XMLTREE/CONVERT Converter an XML tree in a Matlab structure
+% 
+% tree      - XMLTree object
+% uid       - uid of the root of the subtree, if provided.
+%             Default is root
+% s         - converted structure
+%_______________________________________________________________________
+%
+% Convert an xmltree into a Matlab structure, when possible.
+% When several identical tags are present, a cell array is used.
+% The root tag is not saved in the structure.
+% If provided, only the structure corresponding to the subtree defined
+% by the uid UID is returned.
+%_______________________________________________________________________
+% @(#)convert.m                 Guillaume Flandin              02/04/11
+
+% Exemple:
+% tree: <toto><titi>field1</titi><tutu>field2</tutu><titi>field3</titi></toto>
+% toto = convert(tree);
+% <=> toto = struct('titi',{{'field1', 'field3'}},'tutu','field2')
+
+error(nargchk(1,2,nargin));
+
+% Get the root uid of the output structure
+if nargin == 1
+	% Get the root uid of the XML tree
+	root_uid = root(tree);
+else
+	% Uid provided by user
+	root_uid = uid;
+end
+
+% Initialize the output structure
+% struct([]) should be used but this only works with Matlab 6
+% So we create a field that we delete at the end
+%s = struct(get(tree,root_uid,'name'),''); % struct([])
+s = struct('deletedummy','');
+
+%s = sub_convert(tree,s,root_uid,{get(tree,root_uid,'name')});
+s = sub_convert(tree,s,root_uid,{});
+
+s = rmfield(s,'deletedummy');
+
+%=======================================================================
+function s = sub_convert(tree,s,uid,arg)
+	type = get(tree,uid,'type');
+	switch type
+		case 'element'
+			child = children(tree,uid);
+			l = {};
+			ll = {};
+			for i=1:length(child)
+				if isfield(tree,child(i),'name')
+					ll = { ll{:}, get(tree,child(i),'name') };
+				end
+			end
+			for i=1:length(child)
+				if isfield(tree,child(i),'name')
+					name = get(tree,child(i),'name');
+					nboccur = sum(ismember(l,name));
+					nboccur2 = sum(ismember(ll,name));
+					l = { l{:}, name };
+					if nboccur | (nboccur2>1)
+						arg2 = { arg{:}, name, {nboccur+1} };
+					else
+						arg2 = { arg{:}, name};
+					end
+				else
+					arg2 = arg;
+				end
+				s = sub_convert(tree,s,child(i),arg2);
+			end
+			if isempty(child)
+				s = sub_setfield(s,arg{:},'');
+			end
+		case 'chardata'
+			s = sub_setfield(s,arg{:},get(tree,uid,'value'));
+		case 'cdata'
+			s = sub_setfield(s,arg{:},get(tree,uid,'value'));
+		case 'pi'
+			% Processing instructions are evaluated if possible
+			app = get(tree,uid,'target');
+			switch app
+				case {'matlab',''}
+					s = sub_setfield(s,arg{:},eval(get(tree,uid,'value')));
+				case 'unix'
+					s = sub_setfield(s,arg{:},unix(get(tree,uid,'value')));
+				case 'dos'
+					s = sub_setfield(s,arg{:},dos(get(tree,uid,'value')));
+				case 'system'
+					s = sub_setfield(s,arg{:},system(get(tree,uid,'value')));
+				otherwise
+					try,
+						s = sub_setfield(s,arg{:},feval(app,get(tree,uid,'value')));
+					catch,
+						warning('[Xmltree/convert] Unknown target application');
+					end
+			end
+		case 'comment'
+			% Comments are forgotten
+		otherwise
+			warning(sprintf('Type %s unknown : not saved',get(tree,uid,'type')));
+	end
+	
+%=======================================================================
+function s = sub_setfield(s,varargin)
+% Same as setfield but using '{}' rather than '()'
+%if (isempty(varargin) | length(varargin) < 2)
+%    error('Not enough input arguments.');
+%end
+
+subs = varargin(1:end-1);
+for i = 1:length(varargin)-1
+    if (isa(varargin{i}, 'cell'))
+        types{i} = '{}';
+    elseif isstr(varargin{i})
+        types{i} = '.';
+        subs{i} = varargin{i}; %strrep(varargin{i},' ',''); % deblank field name
+    else
+        error('Inputs must be either cell arrays or strings.');
+    end
+end
+
+% Perform assignment
+try
+   s = builtin('subsasgn', s, struct('type',types,'subs',subs), varargin{end});
+catch
+   error(lasterr)
+end
Index: /trunk/src/@xmltree/copy.m
===================================================================
--- /trunk/src/@xmltree/copy.m	(revision 723)
+++ /trunk/src/@xmltree/copy.m	(revision 723)
@@ -0,0 +1,45 @@
+function tree = copy(tree,subuid,uid)
+% XMLTREE/COPY Copy Method (copy a subtree in another branch)
+% FORMAT tree = copy(tree,subuid,uid)
+% 
+% tree      - XMLTree object
+% subuid    - UID of the subtree to copy
+% uid       - UID of the element where the subtree must be duplicated
+%_______________________________________________________________________
+%
+% Copy a subtree to another branch
+% The tree parameter must be in input AND in output
+%_______________________________________________________________________
+% @(#)copy.m                   Guillaume Flandin               02/04/08
+
+error(nargchk(2,3,nargin));
+if nargin == 2
+	uid = parent(tree,subuid);
+end
+
+l = length(tree);
+tree = sub_copy(tree,subuid,uid);
+tree.tree{uid}.contents = [tree.tree{uid}.contents l+1];
+
+% pour que la copie soit a cote de l'original et pas a la fin ?
+%  contents = get(tree,parent,'contents');
+%  i = find(contents==uid);
+%  tree = set(tree,parent,'contents',[contents(1:i) l+1 contents(i+1:end)]);
+
+%=======================================================================
+function tree = sub_copy(tree,uid,p)
+
+	l = length(tree);
+	tree.tree{l+1} = tree.tree{uid};
+	tree.tree{l+1}.uid = l+1;
+	tree.tree{l+1}.parent = p;
+	tree.tree{l+1}.contents = [];
+	if isfield(tree.tree{uid},'contents')
+		contents = get(tree,uid,'contents');
+		m = length(tree);
+		for i=1:length(contents)
+			tree.tree{l+1}.contents = [tree.tree{l+1}.contents m+1];
+			tree = sub_copy(tree,contents(i),l+1);
+			m = length(tree);
+		end
+	end
Index: /trunk/src/@xmltree/delete.m
===================================================================
--- /trunk/src/@xmltree/delete.m	(revision 723)
+++ /trunk/src/@xmltree/delete.m	(revision 723)
@@ -0,0 +1,33 @@
+function tree = delete(tree,uid)
+% XMLTREE/DELETE Delete (delete a subtree given its UID)
+% 
+% tree      - XMLTree object
+% uid       - array of UID's of subtrees to be deleted
+%_______________________________________________________________________
+%
+% Delete a subtree given its UID
+% The tree parameter must be in input AND in output
+%_______________________________________________________________________
+% @(#)delete.m                 Guillaume Flandin               02/04/08
+
+error(nargchk(2,2,nargin));
+
+uid = uid(:);
+for i=1:length(uid)
+	if uid(i)==1
+		warning('[XMLTree] Cannot delete root element.');
+	else
+		p = tree.tree{uid(i)}.parent;
+		tree = sub_delete(tree,uid(i));
+		tree.tree{p}.contents(find(tree.tree{p}.contents==uid(i))) = [];
+	end
+end
+
+%=======================================================================
+function tree = sub_delete(tree,uid)
+	if isfield(tree.tree{uid},'contents')
+		for i=1:length(tree.tree{uid}.contents)
+			tree = sub_delete(tree,tree.tree{uid}.contents(i));
+		end
+	end
+	tree.tree{uid} = struct('type','deleted');
Index: /trunk/src/@xmltree/display.m
===================================================================
--- /trunk/src/@xmltree/display.m	(revision 723)
+++ /trunk/src/@xmltree/display.m	(revision 723)
@@ -0,0 +1,19 @@
+function display(tree)
+% XMLTREE/DISPLAY Command window display of an XMLTree
+% FORMAT display(tree)
+% 
+% tree - XMLTree object
+%_______________________________________________________________________
+%
+% This method is called when the semicolon is not used to terminate a
+% statement which returns an XMLTree.
+%_______________________________________________________________________
+% @(#)display.m                  Guillaume Flandin             02/04/04
+
+disp(' ');
+disp([inputname(1),' = ']);
+disp(' ');
+for i=1:prod(size(tree))
+	disp([blanks(length(inputname(1))+3) char(tree(i))]);
+end
+disp(' ');
Index: /trunk/src/@xmltree/find.m
===================================================================
--- /trunk/src/@xmltree/find.m	(revision 723)
+++ /trunk/src/@xmltree/find.m	(revision 723)
@@ -0,0 +1,171 @@
+function list = find(varargin)
+% XMLTREE/FIND Find elements in a tree with specified characteristics
+% FORMAT list = find(varargin)
+%
+% tree  - XMLTree object
+% xpath - string path with specific grammar (XPath)
+% uid   - lists of root uid's
+% parameter/value - pair of pattern
+% list  - list of uid's of matched elements
+%
+%      list = find(tree,xpath)
+%      list = find(tree,parameter,value[,parameter,value])
+%      list = find(tree,uid,parameter,value[,parameter,value])
+%
+% Grammar for addressing parts of an XML document: 
+%        XML Path Language XPath (http://www.w3.org/TR/xpath)
+% Example: /element1//element2[1]/element3[5]/element4
+%_______________________________________________________________________
+%
+% Find elements in an XML tree with specified characteristics or given
+% a path (using a subset of XPath language).
+%_______________________________________________________________________
+% @(#)find.m                 Guillaume Flandin                 01/10/29
+
+% TODO:
+%   - clean up subroutines
+%   - find should only be documented using XPath (other use is internal)
+%   - handle '*', 'last()' in [] and '@'
+%   - if a key is invalid, should rather return [] than error ?
+
+if nargin==0
+	error('[XMLTree] A tree must be provided');
+elseif nargin==1
+	list = 1:length(tree.tree);
+	return
+elseif mod(nargin,2)
+	list = sub_find_subtree1(varargin{1}.tree,root(tree),varargin{2:end});
+elseif isa(varargin{2},'double') & ...
+	   ndims(varargin{2}) == 2 & ...
+	   min(size(varargin{2})) == 1
+	list = unique(sub_find_subtree1(varargin{1}.tree,varargin{2:end}));
+elseif nargin==2 & ischar(varargin{2})
+	list = sub_pathfinder(varargin{:});
+else
+   error('[XMLTree] Arguments must be parameter/value pairs.');
+end
+
+%=======================================================================
+function list = sub_find_subtree1(varargin)
+	list = [];
+	for i=1:length(varargin{2})
+		res = sub_find_subtree2(varargin{1},...
+				varargin{2}(i),varargin{3:end});
+		list = [list res];
+	end
+
+%=======================================================================
+function list = sub_find_subtree2(varargin)
+	uid = varargin{2};
+	list = [];
+	if sub_comp_element(varargin{1}{uid},varargin{3:end})
+		list = [list varargin{1}{uid}.uid];
+	end
+	if isfield(varargin{1}{uid},'contents')
+		list = [list sub_find_subtree1(varargin{1},...
+		        varargin{1}{uid}.contents,varargin{3:end})];
+	end
+
+%=======================================================================
+function match = sub_comp_element(varargin)
+match = 0;
+try,
+	% v = getfield(varargin{1}, varargin{2}); % slow...
+	for i=1:floor(nargin/2)
+		v = subsref(varargin{1}, struct('type','.','subs',varargin{i+1}));     
+		if strcmp(v,varargin{i+2})
+			match = 1;
+		end
+	end
+catch,
+end
+
+% More powerful but much slower
+%match = 0;
+%for i=1:length(floor(nargin/2)) % bug: remove length !!!
+%   if isfield(varargin{1},varargin{i+1})
+%	  if ischar(getfield(varargin{1},varargin{i+1})) & ischar(varargin{i+2})
+%	   if strcmp(getfield(varargin{1},varargin{i+1}),char(varargin{i+2}))
+%			match = 1;
+%		 end
+%	  elseif isa(getfield(varargin{1},varargin{i+1}),'double') & ...
+%			isa(varargin{i+2},'double')
+%		 if getfield(varargin{1},varargin{i+1}) == varargin{i+2}
+%			match = 1;
+%		end
+%	 else 
+%		warning('Cannot compare different objects');
+%	  end
+%   end
+%end
+
+%=======================================================================
+function list = sub_pathfinder(tree,pth)
+	%- Search for the delimiter '/' in the path
+	i = findstr(pth,'/');
+	%- Begin search by root
+	list = root(tree);
+	%- Walk through the tree
+	j = 1;
+	while j <= length(i)
+		%- Look for recursion '//'
+		if j<length(i) & i(j+1)==i(j)+1
+			recursive = 1;
+			j = j + 1;
+		else
+			recursive = 0;
+		end
+		%- Catch the current tag 'element[x]'
+		if j ~= length(i)
+			element = pth(i(j)+1:i(j+1)-1);
+		else
+			element = pth(i(j)+1:end);
+		end
+		%- Search for [] brackets
+		k = xml_findstr(element,'[',1,1);
+		%- If brackets are present in current element
+		if ~isempty(k)
+			l   = xml_findstr(element,']',1,1);
+			val = str2num(element(k+1:l-1));
+			element = element(1:k-1);
+		end
+		%- Use recursivity
+		if recursive
+			list = find(tree,list,'name',element);
+		%- Just look at children
+		else
+			if i(j)==1 % if '/root/...' (list = root(tree) in that case)
+				if sub_comp_element(tree.tree{list},'name',element)
+					% list = 1; % list still contains root(tree)
+				else
+					list = [];
+					return;
+				end
+			else
+				list = sub_findchild(tree,list,element);
+			end
+		end
+		% If an element is specified using a key
+		if ~isempty(k)
+			if val < 1 | val > length(list)+1
+				error('[XMLTree] Bad key in the path.');
+			elseif val == length(list)+1
+				list = [];
+				return;
+			end
+			list = list(val);
+		end
+		if isempty(list), return; end
+		j = j + 1;
+	end
+	
+%=======================================================================
+function list = sub_findchild(tree,listt,elmt)
+	list = [];
+	for a=1:length(listt)
+		for b=1:length(tree.tree{listt(a)}.contents)
+			if sub_comp_element(tree.tree{tree.tree{listt(a)}.contents(b)},'name',elmt)
+				list = [list tree.tree{tree.tree{listt(a)}.contents(b)}.uid];
+			end
+		end
+	end
Index: /trunk/src/@xmltree/flush.m
===================================================================
--- /trunk/src/@xmltree/flush.m	(revision 723)
+++ /trunk/src/@xmltree/flush.m	(revision 723)
@@ -0,0 +1,39 @@
+function tree = flush(tree,uid)
+% XMLTREE/FLUSH Flush (Clear a subtree given its UID)
+% 
+% tree      - XMLTree object
+% uid       - array of UID's of subtrees to be cleared
+%             Default is root
+%_______________________________________________________________________
+%
+% Clear a subtree given its UID (remove all the leaves of the tree)
+% The tree parameter must be in input AND in output
+%_______________________________________________________________________
+% @(#)flush.m                  Guillaume Flandin               02/04/10
+
+error(nargchk(1,2,nargin));
+
+if nargin == 1,
+	uid = root(tree);
+end
+
+uid = uid(:);
+for i=1:length(uid)
+	 tree = sub_flush(tree,uid(i));
+end
+
+%=======================================================================
+function tree = sub_flush(tree,uid)
+	if isfield(tree.tree{uid},'contents')
+		% contents is parsed in reverse order because each child is
+		% deleted and the contents vector is then eventually reduced
+		for i=length(tree.tree{uid}.contents):-1:1
+			tree = sub_flush(tree,tree.tree{uid}.contents(i));
+		end
+	end
+	if strcmp(tree.tree{uid}.type,'chardata') |...
+		strcmp(tree.tree{uid}.type,'pi') |...
+		strcmp(tree.tree{uid}.type,'cdata') |...
+		strcmp(tree.tree{uid}.type,'comment')
+		tree = delete(tree,uid);
+	end
Index: /trunk/src/@xmltree/get.m
===================================================================
--- /trunk/src/@xmltree/get.m	(revision 723)
+++ /trunk/src/@xmltree/get.m	(revision 723)
@@ -0,0 +1,39 @@
+function value = get(tree,uid,parameter)
+% XMLTREE/GET Get Method (get object properties)
+% FORMAT value = get(tree,uid,parameter)
+% 
+% tree      - XMLTree object
+% uid       - array of uid's
+% parameter - property name
+% value     - property value
+%_______________________________________________________________________
+%
+% Get object properties of a tree given their UIDs.
+%_______________________________________________________________________
+% @(#)get.m                   Guillaume Flandin                02/03/27
+
+error(nargchk(2,3,nargin));
+
+value = cell(size(uid));
+uid = uid(:);
+if nargin==2
+	for i=1:length(uid)
+		if uid(i)<1 | uid(i)>length(tree.tree)
+			error('[XMLTree] Invalid UID.');
+		end
+		% According to the type of the node, return only some parameters
+		% Need changes...
+		value{i} = tree.tree{uid(i)};
+	end
+else
+	for i=1:length(uid)
+		try,
+			value{i} = subsref(tree.tree{uid(i)}, struct('type','.','subs',parameter));
+		catch,
+			error(sprintf('[XMLTree] Parameter %s not found.',parameter));
+		end
+	end 
+end
+if length(value)==1
+	value = value{1};
+end  
Index: /trunk/src/@xmltree/getfilename.m
===================================================================
--- /trunk/src/@xmltree/getfilename.m	(revision 723)
+++ /trunk/src/@xmltree/getfilename.m	(revision 723)
@@ -0,0 +1,14 @@
+function filename = getfilename(tree)
+% XMLTREE/GETFILENAME Get filename method
+% FORMAT filename = getfilename(tree)
+% 
+% tree     - XMLTree object
+% filename - XML filename
+%_______________________________________________________________________
+%
+% Return the filename of the XML tree if loaded from disk and an empty 
+% string otherwise.
+%_______________________________________________________________________
+% @(#)getfilename.m               Guillaume Flandin            02/03/27
+
+filename = tree.filename;
Index: /trunk/src/@xmltree/isfield.m
===================================================================
--- /trunk/src/@xmltree/isfield.m	(revision 723)
+++ /trunk/src/@xmltree/isfield.m	(revision 723)
@@ -0,0 +1,22 @@
+function F = isfield(tree,uid,parameter)
+% XMLTREE/ISFIELD Is parameter a field of tree{uid} ?
+% FORMAT F = isfield(tree,uid,parameter)
+%
+% tree      - a tree
+% uid       - uid of the element
+% parameter - a field of the root tree
+% F         - 1 if present, 0 otherwise
+%_______________________________________________________________________
+%
+% Is parameter a field of tree{uid} ?
+%_______________________________________________________________________
+% @(#)isfield.m               Guillaume Flandin                01/10/31
+
+error(nargchk(3,3,nargin));
+
+F = zeros(1,length(uid));
+for i=1:length(uid)
+	if isfield(tree.tree{uid(i)},parameter)
+		F(i) = 1;
+	end
+end
Index: /trunk/src/@xmltree/length.m
===================================================================
--- /trunk/src/@xmltree/length.m	(revision 723)
+++ /trunk/src/@xmltree/length.m	(revision 723)
@@ -0,0 +1,33 @@
+function l = length(tree,r)
+% XMLTREE/LENGTH Length Method
+% FORMAT l = length(tree,r)
+% 
+% tree - XMLTree object
+% r    - 'real' if present, returns the real number of nodes in the
+%         tree (deleted nodes aren't populated)
+% l    - length of the XML tree (number of nodes)
+%_______________________________________________________________________
+%
+% Return the number of nodes of an XMLTree object.
+%_______________________________________________________________________
+% @(#)length.m                 Guillaume Flandin               02/03/27
+
+error(nargchk(1,2,nargin));
+
+% Return the full number of nodes once allocated
+l = length(tree.tree);
+
+% Substract the number of deleted nodes to the previous length
+if nargin == 2
+	if strcmp(r,'real')
+		ll = 0;
+		for i=1:l
+			if ~strcmp(tree.tree{i}.type,'deleted')
+				ll = ll + 1;
+			end
+		end
+		l = ll;
+	else
+		error('[XMLTree] Bad input argument.');
+	end
+end
Index: /trunk/src/@xmltree/move.m
===================================================================
--- /trunk/src/@xmltree/move.m	(revision 723)
+++ /trunk/src/@xmltree/move.m	(revision 723)
@@ -0,0 +1,18 @@
+function tree = move(tree,uida, uidb)
+% XMLTREE/MOVE Move (move a subtree inside a tree from A to B)
+% 
+% tree   - XMLTree object
+% uida   - initial position of the subtree
+% uidb   - parent of the final position of the subtree
+%_______________________________________________________________________
+%
+% Move a subtree inside a tree from A to B.
+% The tree parameter must be in input AND in output
+%_______________________________________________________________________
+% @(#)move.m                  Guillaume Flandin                02/04/08
+
+error(nargchk(3,3,nargin));
+
+p = tree.tree{uida}.parent;
+tree.tree{p}.contents(find(tree.tree{p}.contents==uida)) = [];
+tree.tree(uidb).contents = [tree.tree(uidb).contents uida];
Index: /trunk/src/@xmltree/parent.m
===================================================================
--- /trunk/src/@xmltree/parent.m	(revision 723)
+++ /trunk/src/@xmltree/parent.m	(revision 723)
@@ -0,0 +1,14 @@
+function p = parent(tree,uid)
+% XMLTREE/PARENT Parent Method
+% FORMAT uid = parent(tree,uid)
+% 
+% tree   - XMLTree object
+% uid    - UID of the lonely child
+% p      - UID of the parent ([] if root is the child)
+%_______________________________________________________________________
+%
+% Return the uid of the parent of a node.
+%_______________________________________________________________________
+% @(#)parent.m                  Guillaume Flandin              02/04/08
+
+p = tree.tree{uid}.parent;
Index: /trunk/src/@xmltree/private/xml_findstr.c
===================================================================
--- /trunk/src/@xmltree/private/xml_findstr.c	(revision 723)
+++ /trunk/src/@xmltree/private/xml_findstr.c	(revision 723)
@@ -0,0 +1,103 @@
+#include "mex.h"
+
+/*
+    Differences with matlab built-in findstr:
+        - allows to search only the n first occurences of a pattern
+        - allows to search only in a substring (given an index of the beginning)
+   
+    Matlab hack:
+        - doesn't use mxGetString to prevent a copy of the string.
+        - assumes Matlab stores strings as unsigned short (Unicode 16 bits)
+          matrix.h: typedef uint16_T mxChar;
+          (that's the case for Matlab 5.* and 6.* but Matlab 4.* stores strings
+           as double)
+*/
+
+/* Comment the following line to use standard mxGetString (slower) */
+#define __HACK_MXCHAR__
+
+void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
+
+    unsigned int i, j, stext, spattern, nbmatch = 0, ind = 1, occur = 0, nboccur = 0;
+#ifdef __HACK_MXCHAR__
+    unsigned short int *text = NULL, *pattern = NULL;
+#else
+    char *text = NULL, *pattern = NULL;
+#endif
+    unsigned int *k = NULL;
+    mxArray *out = NULL;
+    
+	/* Check for proper number of arguments. */
+    if ((nrhs == 0) || (nrhs == 1))
+	    mexErrMsgTxt("Not enough input arguments.");
+    else if (nrhs > 4)
+	    mexErrMsgTxt("Too many input arguments.");
+    else if (nlhs > 1)
+        mexErrMsgTxt("Too many output arguments.");
+    
+    /* The input TEXT must be a string */
+	if (!mxIsChar(prhs[0]))
+	    mexErrMsgTxt("Inputs must be character arrays.");
+	stext = mxGetM(prhs[0]) * mxGetN(prhs[0]);
+#ifdef __HACK_MXCHAR__
+	text = mxGetData(prhs[0]);
+#else
+    text = mxCalloc(stext+1, sizeof(char));
+    mxGetString(prhs[0], text, stext+1);
+#endif
+        
+    /* The input PATTERN must be a string */
+	if (!mxIsChar(prhs[1]))
+		mexErrMsgTxt("Inputs must be character arrays.");
+    spattern = mxGetM(prhs[1]) * mxGetN(prhs[1]);
+#ifdef __HACK_MXCHAR__
+	pattern = mxGetData(prhs[1]);
+#else
+    pattern = mxCalloc(spattern+1, sizeof(char));
+	mxGetString(prhs[1], pattern, spattern+1);
+#endif
+
+	/* The input INDEX must be an integer */
+	if (nrhs > 2) {
+	    if ((!mxIsNumeric(prhs[2]) || (mxGetM(prhs[2]) * mxGetN(prhs[2]) !=  1)))
+	        mexErrMsgTxt("Index input must be an integer.");
+	    ind = (unsigned int)mxGetScalar(prhs[2]);
+	    if (ind < 1)
+	        mexErrMsgTxt("Index must be greater than 1.");
+	}
+	
+	/* The input OCCUR must be an integer */
+	if (nrhs == 4) {
+	    if ((!mxIsNumeric(prhs[3]) || (mxGetM(prhs[3]) * mxGetN(prhs[3]) !=  1)))
+	        mexErrMsgTxt("Index input must be an integer.");
+	    nboccur = (unsigned int)mxGetScalar(prhs[3]);
+	}
+	
+	/* Find pattern in text */
+    for (i=ind-1;i<stext;i++) {
+        for (j=0;j<spattern && i+j<stext;j++) {
+            if (pattern[j] == text[i+j]) {
+                if (j == spattern-1) {
+                    nbmatch += 1;
+                    k = mxRealloc(k,nbmatch*sizeof(unsigned int));
+                    k[nbmatch-1] = i+1;
+                    if (++occur == nboccur) i = stext;
+                }
+            }
+            else break;
+        }
+    }
+    
+    /* Allocate output */
+    out = mxCreateDoubleMatrix((nbmatch) ? 1:0, nbmatch, mxREAL);
+    
+    /* Copy index array into output */
+    for (i=0;i<nbmatch;i++)
+        mxGetPr(out)[i] = (double)k[i];
+    
+    /* Assign pointer to output */
+    plhs[0] = out;
+    
+    /* Free memory */
+    if (k) mxFree(k);
+}
Index: /trunk/src/@xmltree/private/xml_findstr.m
===================================================================
--- /trunk/src/@xmltree/private/xml_findstr.m	(revision 723)
+++ /trunk/src/@xmltree/private/xml_findstr.m	(revision 723)
@@ -0,0 +1,28 @@
+function k = xml_findstr(s,p,i,n)
+%XML_FINDSTR Find one string within another
+%   K = XML_FINDSTR(TEXT,PATTERN) returns the starting indices of any 
+%   occurrences of the string PATTERN in the string TEXT.
+%
+%   K = XML_FINDSTR(TEXT,PATTERN,INDICE) returns the starting indices 
+%   equal or greater than INDICE of occurrences of the string PATTERN
+%   in the string TEXT. By default, INDICE equals to one.
+%
+%   K = XML_FINDSTR(TEXT,PATTERN,INDICE,NBOCCUR) returns the NBOCCUR 
+%   starting indices equal or greater than INDICE of occurrences of
+%   the string PATTERN in the string TEXT. By default, INDICE equals
+%   to one and NBOCCUR equals to Inf.
+%
+%   Examples
+%       s = 'How much wood would a woodchuck chuck?';
+%       xml_findstr(s,' ') returns [4 9 14 20 22 32]
+%       xml_findstr(s,' ',10) returns [14 20 22 32]
+%       xml_findstr(s,' ',10,1) returns 14
+%
+%   See also STRFIND, FINDSTR
+
+%   Guillaume Flandin
+%   Copyright 2002 INRIA Sophia Antipolis
+%   $Revision: 1.0 $  $Date: 2002/04/10 22:50:32 $
+%   Implemented in a MATLAB mex file.
+
+error(sprintf('Missing MEX-file: %s', mfilename));
Index: /trunk/src/@xmltree/private/xml_parser.m
===================================================================
--- /trunk/src/@xmltree/private/xml_parser.m	(revision 723)
+++ /trunk/src/@xmltree/private/xml_parser.m	(revision 723)
@@ -0,0 +1,428 @@
+function tree = xml_parser(filename)
+% XML (eXtensible Markup Language) Processor
+% FORMAT tree = xml_parser(filename)
+%
+% filename - XML file to parse
+% tree     - tree structure corresponding to the XML file
+%_______________________________________________________________________
+%
+% xml_parser.m is an XML 1.0 (http://www.w3.org/TR/REC-xml) parser
+% written in Matlab. It aims to be fully conforming. It is currently not
+% a validating XML processor.
+% (based on a Javascript parser available at http://www.jeremie.com)
+%
+% A description of the tree structure provided in output is detailed in 
+% the header of this m-file.
+%_______________________________________________________________________
+% @(#)xml_parser.m               Guillaume Flandin           2002/04/04
+
+% XML Processor for MATLAB (The Mathworks, Inc.).
+% Copyright (C) 2002  Guillaume Flandin
+%
+% This program is free software; you can redistribute it and/or
+% modify it under the terms of the GNU General Public License
+% as published by the Free Software Foundation; either version 2
+% of the License, or any later version.
+%
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+% 
+% You should have received a copy of the GNU General Public License
+% along with this program; if not, write to the Free Software
+% Foundation Inc, 59 Temple Pl. - Suite 330, Boston, MA 02111-1307, USA.
+%-----------------------------------------------------------------------
+
+% Please feel free to email the author any comment/suggestion/bug report
+% to improve this XML processor in Matlab.
+% Email: Guillaume.Flandin@sophia.inria.fr
+% Check also the latest developments on the following webpage:
+% http://www-sop.inria.fr/epidaure/personnel/flandin/xml/
+%-----------------------------------------------------------------------
+
+% A mex-file xml_findstr.c is also required, to encompass some
+% limitations of the built-in findstr Matlab function.
+% Compile it on your architecture using 'mex -O xml_findstr.c' command
+% if the compiled version for your system is not provided.
+% If this function behaves badly (crash or wrong results), comment the
+% line '#define __HACK_MXCHAR__' in xml_findstr.c and compile it again.
+%-----------------------------------------------------------------------
+
+% Structure of the output tree:
+% There are 5 types of nodes in an XML file: element, chardata, cdata,
+% pi and comment.
+% Each of them contains an UID (Unique Identifier): an integer between
+% 1 and the number of nodes of the XML file.
+%
+%    element (a tag <name key="value"> [contents] </name>
+%       |_ type:       'element'
+%       |_ name:       string
+%       |_ attributes: cell array of struct 'key' and 'value' or []
+%       |_ contents:   double array of uid's or [] if empty
+%       |_ parent:     uid of the parent ([] if root)
+%       |_ uid:        double
+%
+%    chardata (a character array)
+%       |_ type:   'chardata'
+%       |_ value:  string
+%       |_ parent: uid of the parent
+%       |_ uid:    double
+%
+%    cdata (a litteral string <![CDATA[value]]>)
+%       |_ type:   'cdata'
+%       |_ value:  string
+%       |_ parent: uid of the parent
+%       |_ uid:    double
+%
+%      pi (a processing instruction <?target value ?>)
+%       |_ type:   'pi' 
+%       |_ target: string (may be empty)
+%       |_ value:  string
+%       |_ parent: uid of the parent
+%       |_ uid:    double
+%
+%    comment (a comment <!-- value -->)
+%       |_ type:   'comment'
+%       |_ value:  string
+%       |_ parent: uid of the parent
+%       |_ uid:    double
+%
+%-----------------------------------------------------------------------
+
+% TODO/BUG/FEATURES:
+%  - [compile] only a warning if TagStart is empty
+%  - [attribution] should look for " and ' rather than only "
+%  - [main] with normalize as a preprocessing, CDATA are modified
+%  - [prolog] look for a DOCTYPE in the whole string even if it occurs
+%    only in a far CDATA tag (for example)...
+%  - [tag_element] erode should replace normalize here
+%  - remove globals? uppercase globals  rather persistent (clear mfile)?
+%  - xml_findst is in fact xml_strfind according to Mathworks vocabulary
+%  - problem with entity (don't know if the bug is here or in save fct.)
+%-----------------------------------------------------------------------
+
+%- XML string to parse and number of tags read
+global xmlstring Xparse_count xtree;
+
+%- Check input arguments
+error(nargchk(1,1,nargin));
+if isempty(filename)
+	error('Not enough parameters.')
+elseif ~isstr(filename) | sum(size(filename)>1)>1
+	error('Input must be a string filename.')
+end
+
+%- Read the entire XML file
+fid = fopen(filename,'rt');
+if (fid==-1) 
+	error(sprintf('Cannot open %s for reading.',filename))
+end
+xmlstring = fscanf(fid,'%c');
+fclose(fid);
+
+%- Initialize number of tags (<=> uid)
+Xparse_count = 0;
+
+%- Remove prolog and white space characters from the XML string
+xmlstring = normalize(prolog(xmlstring));
+
+%- Initialize the XML tree
+xtree = {};
+tree = fragment;
+tree.str = 1;
+tree.parent = 0;
+
+%- Parse the XML string
+tree = compile(tree);
+
+%- Return the XML tree
+tree = xtree;
+
+%- Remove global variables from the workspace
+clear global xmlstring Xparse_count xtree;
+
+%=======================================================================
+% SUBFUNCTIONS
+
+%-----------------------------------------------------------------------
+function frag = compile(frag)
+	global xmlstring xtree Xparse_count;
+	
+	while 1,
+		if length(xmlstring)<=frag.str | ...
+		   (frag.str == length(xmlstring)-1 & strcmp(xmlstring(frag.str:end),' '))
+			return
+		end
+		TagStart = xml_findstr(xmlstring,'<',frag.str,1);
+		if isempty(TagStart)
+			%- Character data (should be an error)
+			warning('[XML] Unknown data at the end of the XML file.');
+			fprintf('Please send me your XML file at gflandin@sophia.inria.fr\n');
+			%thisary = length(frag.ary) + 1;
+			xtree{Xparse_count+1} = chardata;
+			xtree{Xparse_count}.value = erode(entity(xmlstring(frag.str:end)));
+			xtree{Xparse_count}.parent = frag.parent;
+			xtree{frag.parent}.contents = [xtree{frag.parent}.contents Xparse_count];
+			%frag.str = '';
+		elseif TagStart > frag.str
+			if strcmp(xmlstring(frag.str:TagStart-1),' ')
+				%- A single white space before a tag (ignore)
+				frag.str = TagStart;
+			else
+				%- Character data
+				xtree{Xparse_count} = chardata;
+				xtree{Xparse_count}.value = erode(entity(xmlstring(frag.str:TagStart-1)));
+				xtree{Xparse_count}.parent = frag.parent;
+				xtree{frag.parent}.contents = [xtree{frag.parent}.contents Xparse_count];
+				frag.str = TagStart;
+			end
+		else 
+			if strcmp(xmlstring(frag.str+1),'?')
+				%- Processing instruction
+				frag = tag_pi(frag);
+			else
+				if length(xmlstring)-frag.str>4 & strcmp(xmlstring(frag.str+1:frag.str+3),'!--')
+					%- Comment
+					frag = tag_comment(frag);
+				else
+					if length(xmlstring)-frag.str>9 & strcmp(xmlstring(frag.str+1:frag.str+8),'![CDATA[')
+						%- Litteral data
+						frag = tag_cdata(frag);
+					else
+						%- A tag element (empty (<.../>) or not)
+						if ~isempty(frag.end)
+							endmk = ['/' frag.end '>'];
+						else 
+							endmk = '/>';
+						end
+						if strcmp(xmlstring(frag.str+1:frag.str+length(frag.end)+2),endmk) | ...
+							strcmp(strip(xmlstring(frag.str+1:frag.str+length(frag.end)+2)),endmk)
+							frag.str = frag.str + length(frag.end)+3;
+							return
+						else
+							frag = tag_element(frag);
+						end
+					end
+				end
+			end
+		end
+	end
+
+%-----------------------------------------------------------------------
+function frag = tag_element(frag)
+	global xmlstring xtree Xparse_count;
+	close =  xml_findstr(xmlstring,'>',frag.str,1);
+	if isempty(close)
+		error('[XML] Tag < opened but not closed.');
+	else
+		empty = strcmp(xmlstring(close-1:close),'/>');
+		if empty
+			close = close - 1;
+		end
+		starttag = normalize(xmlstring(frag.str+1:close-1));
+		nextspace = xml_findstr(starttag,' ',1,1);
+		attribs = '';
+		if isempty(nextspace)
+			name = starttag;
+		else
+			name = starttag(1:nextspace-1);
+			attribs = starttag(nextspace+1:end);
+		end
+		xtree{Xparse_count} = element;
+		xtree{Xparse_count}.name = strip(name);
+		if frag.parent
+			xtree{Xparse_count}.parent = frag.parent;
+			xtree{frag.parent}.contents = [xtree{frag.parent}.contents Xparse_count];
+		end
+		if length(attribs) > 0
+			xtree{Xparse_count}.attributes = attribution(attribs);
+		end
+		if ~empty
+			contents = fragment;
+			contents.str = close+1;
+			contents.end = name;
+			contents.parent = Xparse_count;
+			contents = compile(contents);
+			frag.str = contents.str;
+		else
+			frag.str = close+2;
+		end
+	end
+
+%-----------------------------------------------------------------------
+function frag = tag_pi(frag)
+	global xmlstring xtree Xparse_count;
+	close = xml_findstr(xmlstring,'?>',frag.str,1);
+	if isempty(close)
+		warning('[XML] Tag <? opened but not closed.')
+	else
+		nextspace = xml_findstr(xmlstring,' ',frag.str,1);
+		xtree{Xparse_count} = pri;
+		if nextspace > close | nextspace == frag.str+2
+			xtree{Xparse_count}.value = erode(xmlstring(frag.str+2:close-1));
+		else
+			xtree{Xparse_count}.value = erode(xmlstring(nextspace+1:close-1));
+			xtree{Xparse_count}.target = erode(xmlstring(frag.str+2:nextspace));
+		end
+		if frag.parent
+			xtree{frag.parent}.contents = [xtree{frag.parent}.contents Xparse_count];
+			xtree{Xparse_count}.parent = frag.parent;
+		end
+		frag.str = close+2;
+	end
+
+%-----------------------------------------------------------------------
+function frag = tag_comment(frag)
+	global xmlstring xtree Xparse_count;
+	close = xml_findstr(xmlstring,'-->',frag.str,1);
+	if isempty(close)
+		warning('[XML] Tag <!-- opened but not closed.')
+	else
+		xtree{Xparse_count} = comment;
+		xtree{Xparse_count}.value = erode(xmlstring(frag.str+4:close-1));
+		if frag.parent
+			xtree{frag.parent}.contents = [xtree{frag.parent}.contents Xparse_count];
+			xtree{Xparse_count}.parent = frag.parent;
+		end
+		frag.str = close+3;
+	end
+
+%-----------------------------------------------------------------------
+function frag = tag_cdata(frag)
+	global xmlstring xtree Xparse_count;
+	close = xml_findstr(xmlstring,']]>',frag.str,1);
+	if isempty(close)
+		warning('[XML] Tag <![CDATA[ opened but not closed.')
+	else
+		xtree{Xparse_count} = cdata;
+		xtree{Xparse_count}.value = xmlstring(frag.str+9:close-1);
+		if frag.parent
+			xtree{frag.parent}.contents = [xtree{frag.parent}.contents Xparse_count];
+			xtree{Xparse_count}.parent = frag.parent;
+		end
+		frag.str = close+3;
+	end
+
+%-----------------------------------------------------------------------
+function all = attribution(str)
+	%- Initialize attributs
+	nbattr = 0;
+	all = cell(nbattr);
+	%- Look for 'key="value"' substrings
+	while 1,
+		eq = xml_findstr(str,'=',1,1);
+		if isempty(str) | isempty(eq), return; end
+		id = xml_findstr(str,'"',1,1);       % should also look for ''''
+		nextid = xml_findstr(str,'"',id+1,1);% rather than only '"'
+		nbattr = nbattr + 1;
+		all{nbattr}.key = strip(str(1:(eq-1)));
+		all{nbattr}.val = entity(str((id+1):(nextid-1)));
+		str = str((nextid+1):end);
+	end
+
+%-----------------------------------------------------------------------
+function elm = element
+	global Xparse_count;
+	Xparse_count = Xparse_count + 1;
+	elm = struct('type','element','name','','attributes',[],'contents',[],'parent',[],'uid',Xparse_count);
+   
+%-----------------------------------------------------------------------
+function cdat = chardata
+	global Xparse_count;
+	Xparse_count = Xparse_count + 1;
+	cdat = struct('type','chardata','value','','parent',[],'uid',Xparse_count);
+   
+%-----------------------------------------------------------------------
+function cdat = cdata
+	global Xparse_count;
+	Xparse_count = Xparse_count + 1;
+	cdat = struct('type','cdata','value','','parent',[],'uid',Xparse_count);
+   
+%-----------------------------------------------------------------------
+function proce = pri
+	global Xparse_count;
+	Xparse_count = Xparse_count + 1;
+	proce = struct('type','pi','value','','target','','parent',[],'uid',Xparse_count);
+
+%-----------------------------------------------------------------------
+function commt = comment
+	global Xparse_count;
+	Xparse_count = Xparse_count + 1;
+	commt = struct('type','comment','value','','parent',[],'uid',Xparse_count);
+
+%-----------------------------------------------------------------------
+function frg = fragment
+	frg = struct('str','','parent','','end','');
+
+%-----------------------------------------------------------------------
+function str = prolog(str)
+	%- Initialize beginning index of elements tree
+	b = 1;
+	%- Initial tag
+	start = xml_findstr(str,'<',1,1);
+	if isempty(start) 
+		error('[XML] No tag found.')
+	end
+	%- Header (<?xml version="1.0" ... ?>)
+	if strcmp(lower(str(start:start+2)),'<?x')
+		close = xml_findstr(str,'?>',1,1);
+		if ~isempty(close) 
+			b = close + 2;
+		else 
+			warning('[XML] Header tag incomplete.')
+		end
+	end
+	%- Doctype (<!DOCTYPE type ... [ declarations ]>)
+	start = xml_findstr(str,'<!DOCTYPE',b,1);  % length('<!DOCTYPE') = 9
+	if ~isempty(start) 
+		close = xml_findstr(str,'>',start+9,1);
+		if ~isempty(close)
+			b = close + 1;
+			dp = xml_findstr(str,'[',start+9,1);
+			if (~isempty(dp) & dp < b)
+				k = xml_findstr(str,']>',start+9,1);
+				if ~isempty(k)
+					b = k + 2;
+				else
+					warning('[XML] Tag [ in DOCTYPE opened but not closed.')
+				end
+			end
+		else
+			warning('[XML] Tag DOCTYPE opened but not closed.')
+		end
+	end
+	%- Skip prolog from the xml string
+	str = str(b:end);
+
+%-----------------------------------------------------------------------
+function str = strip(str)
+	a = isspace(str);
+	a = find(a==1);
+	str(a) = '';
+
+%-----------------------------------------------------------------------
+function str = normalize(str)
+	% Find white characters (space, newline, carriage return, tabs, ...)
+	i = isspace(str);
+	i = find(i == 1);
+	str(i) = ' ';
+	% replace several white characters by only one
+	if ~isempty(i)
+		j = i - [i(2:end) i(end)];
+		k = find(j == -1);
+		str(i(k)) = [];
+	end
+
+%-----------------------------------------------------------------------
+function str = entity(str)
+	str = strrep(str,'&lt;','<');
+	str = strrep(str,'&gt;','>');
+	str = strrep(str,'&quot;','"');
+	str = strrep(str,'&apos;','''');
+	str = strrep(str,'&amp;','&');
+   
+%-----------------------------------------------------------------------
+function str = erode(str)
+	if ~isempty(str) & str(1)==' ' str(1)=''; end;
+	if ~isempty(str) & str(end)==' ' str(end)=''; end;
Index: /trunk/src/@xmltree/root.m
===================================================================
--- /trunk/src/@xmltree/root.m	(revision 723)
+++ /trunk/src/@xmltree/root.m	(revision 723)
@@ -0,0 +1,33 @@
+function uid = root(tree)
+% XMLTREE/ROOT Root Method
+% FORMAT uid = root(tree)
+% 
+% tree   - XMLTree object
+% uid    - UID of the root element of tree
+%_______________________________________________________________________
+%
+% Return the uid of the root element of the tree.
+%_______________________________________________________________________
+% @(#)root.m                   Guillaume Flandin               02/04/17
+
+% Actually root is necessarily the element whos UID is 1, by
+% construction. However, xml_parser should return a tree with a ROOT
+% element with as many children as needed but only ONE *element* child
+% who would be the real root (and this method should return the UID of
+% this element).
+
+uid = 1;
+
+% Update:
+% xml_parser has been modified (not as explained above) to handle the
+% case when several nodes are at the top level of the XML.
+% Example: <!-- beginning --><root>blah blah</root><!-- end -->
+% Now root is the first element node of the tree.
+
+% Look for the first element in the XML Tree
+for i=1:length(tree)
+	if strcmp(get(tree,i,'type'),'element')
+		uid = i;
+		break
+	end
+end
Index: /trunk/src/@xmltree/save.m
===================================================================
--- /trunk/src/@xmltree/save.m	(revision 723)
+++ /trunk/src/@xmltree/save.m	(revision 723)
@@ -0,0 +1,97 @@
+function save(tree, filename)
+% XMLTREE/SAVE Save an XML tree in an XML file
+% FORMAT save(tree,filename)
+%
+% tree     - XMLTree
+% filename - XML output filename
+%_______________________________________________________________________
+%
+% Convert an XML tree into a well-formed XML string and write it into
+% a file or display it (send it to standard output) if no filename is 
+% given.
+%
+%-----------------------------------------------------------------------
+% SUBFUNCTIONS:
+%
+% FORMAT print_subtree(tree,fid,order)
+% Send tree entity XML formatted string to fid using 'order' blanks
+% tree  - XML tree
+% fid   - file identifier
+% uid   - uid of the current element
+% order - order of recursivity
+%
+% FORMAT str = entity(str)
+% Tool to replace input string in internal entities
+% str  - string to modify
+%_______________________________________________________________________
+% @(#)save.m                 Guillaume Flandin                 01/07/11
+
+error(nargchk(1,2,nargin));
+
+prolog = '<?xml version="1.0" ?>\n';
+
+%- Standard output
+if nargin==1
+	fid = 1;
+%- Output specified
+elseif nargin==2
+	%- Filename provided
+	if isstr(filename)
+		[fid, msg] = fopen(filename,'w');
+		if fid==-1, error(msg);end
+		if isempty(tree.filename), tree.filename = filename; end
+	%- File identifier provided
+	elseif isnumeric(filename) & prod(size(filename)) == 1
+		fid = filename;
+		prolog = ''; %- In this option, do not write any prolog
+	%- Rubbish provided
+	else
+		error('[XMLTree] Invalid argument.');
+	end
+end
+
+fprintf(fid,prolog);
+print_subtree(tree,fid);
+
+if nargin==2 & isstr(filename), fclose(fid); end
+
+if nargout==1, varargout{1} = tree; end
+
+%=======================================================================
+function print_subtree(tree,fid,uid,order)
+	if nargin <3, uid = root(tree); end
+	if nargin < 4, order = 0; end
+	fprintf(fid,blanks(3*order));
+	switch tree.tree{uid}.type
+		case 'element'
+			fprintf(fid,'<%s',tree.tree{uid}.name);
+			for i=1:length(tree.tree{uid}.attributes)
+				fprintf(fid,' %s="%s"',...
+				tree.tree{uid}.attributes{i}.key,...
+				tree.tree{uid}.attributes{i}.val);
+			end
+			fprintf(fid,'>\n');
+			for i=1:length(tree.tree{uid}.contents)
+				print_subtree(tree,fid,tree.tree{uid}.contents(i),order+1)
+  			end
+			for i=1:order, fprintf(fid,'   '); end
+			fprintf(fid,'</%s>\n',tree.tree{uid}.name);
+		case 'chardata'
+			fprintf(fid,'%s\n',entity(tree.tree{uid}.value));
+		case 'cdata'
+				fprintf(fid,'<![CDATA[%s]]>\n',tree.tree{uid}.value);
+		case 'pi'
+			fprintf(fid,'<?%s %s?>\n',tree.tree{uid}.target,tree.tree{uid}.value);
+		case 'comment'
+			fprintf(fid,'<!-- %s -->\n',tree.tree{uid}.value);
+		otherwise
+			warning(sprintf('Type %s unknown : not saved',tree.tree{uid}.type));
+	end
+   
+%=======================================================================
+function str = entity(str)
+	str = strrep(str,'&','&amp;');
+	str = strrep(str,'<','&lt;');
+	str = strrep(str,'>','&gt;');
+	str = strrep(str,'"','&quot;');
+	str = strrep(str,'\','&apos;');
Index: /trunk/src/@xmltree/set.m
===================================================================
--- /trunk/src/@xmltree/set.m	(revision 723)
+++ /trunk/src/@xmltree/set.m	(revision 723)
@@ -0,0 +1,23 @@
+function tree = set(tree,uid, parameter, value)
+% XMLTREE/SET Method (set object properties)
+% FORMAT tree = set(tree,uid,parameter,value)
+% 
+% tree      - XMLTree object
+% uid       - array (or cell) of uid's
+% parameter - property name
+% value     - property value
+%_______________________________________________________________________
+%
+% Set object properties given its uid and pairs parameter/value
+% The tree parameter must be in input AND in output
+%_______________________________________________________________________
+% @(#)set.m                   Guillaume Flandin                02/03/27
+
+error(nargchk(4,4,nargin));
+
+if iscell(uid), uid = [uid{:}]; else uid = uid(:); end
+
+for i=1:length(uid)
+	tree.tree{uid(i)} = builtin('subsasgn', tree.tree{uid(i)}, struct('type','.','subs',parameter), value);
+	%tree.tree{uid(i)} = setfield(tree.tree{uid(i)},parameter,value);
+end
Index: /trunk/src/@xmltree/setfilename.m
===================================================================
--- /trunk/src/@xmltree/setfilename.m	(revision 723)
+++ /trunk/src/@xmltree/setfilename.m	(revision 723)
@@ -0,0 +1,13 @@
+function tree = setfilename(tree,filename)
+% XMLTREE/SETFILENAME Set filename method
+% FORMAT tree = setfilename(tree,filename)
+% 
+% tree     - XMLTree object
+% filename - XML filename
+%_______________________________________________________________________
+%
+% Set the filename linked to the XML tree as filename.
+%_______________________________________________________________________
+% @(#)setfilename.m               Guillaume Flandin            02/03/27
+
+tree.filename = filename;
Index: /trunk/src/@xmltree/view.m
===================================================================
--- /trunk/src/@xmltree/view.m	(revision 723)
+++ /trunk/src/@xmltree/view.m	(revision 723)
@@ -0,0 +1,209 @@
+function view(tree)
+% XMLTREE/VIEW View Method
+% FORMAT view(tree)
+% 
+% tree   - XMLTree object
+%_______________________________________________________________________
+%
+% Display an XML tree in a graphical interface
+%_______________________________________________________________________
+% @(#)view.m                  Guillaume Flandin                02/04/08
+
+error(nargchk(1,1,nargin));
+
+%-Build the Graphical User Interface
+%-----------------------------------------------------------------------
+figH = findobj('Tag','mlBatchFigure'); %this tag doesn't exist so a new 
+% window is created ....
+if isempty(figH)
+	h = xmltree_build_ui;
+	figH = h.fig;
+else
+   set(figH,'Visible','on');
+   % recover all the handles
+   % h = struct(...);
+end
+drawnow;
+
+%-New title for the main window
+%-----------------------------------------------------------------------
+set(figH,'Name',['XML TreeViewer:' getfilename(tree)]);
+
+
+%-Initialize batch listbox
+%-----------------------------------------------------------------------
+tree = set(tree,root(tree),'show',1);
+builtin('set',figH,'UserData',tree);
+
+view_ui('update',figH);
+
+%=======================================================================
+function handleStruct = xmltree_build_ui
+
+%- Create Figure
+pixfactor = 72 / get(0,'screenpixelsperinch');
+%- Figure window size and position
+oldRootUnits   = get(0,'Units');
+set(0, 'Units', 'points');
+figurePos      = get(0,'DefaultFigurePosition');
+figurePos(3:4) = [560 420];
+figurePos      = figurePos * pixfactor;
+rootScreenSize = get(0,'ScreenSize');
+if ((figurePos(1) < 1) ...
+	  | (figurePos(1)+figurePos(3) > rootScreenSize(3)))
+   figurePos(1) = 30;
+end
+set(0, 'Units', oldRootUnits);
+if ((figurePos(2)+figurePos(4)+60 > rootScreenSize(4)) ...
+	  | (figurePos(2) < 1))
+   figurePos(2) = rootScreenSize(4) - figurePos(4) - 60;
+end
+%- Create Figure Window
+handleStruct.fig = figure(...
+	'Name','XML TreeViewer', ...
+	'Units', 'points', ...
+	'NumberTitle','off', ...
+	'Resize','on', ...
+	'Color',[0.8 0.8 0.8],...
+	'Position',figurePos, ...
+	'MenuBar','none', ... 
+	'Tag', 'BatchFigure', ...
+	'CloseRequestFcn','view_ui close');
+
+%- Build batch listbox
+batchListPos = [20 55 160 345] * pixfactor;
+batchString = ' ';
+handleStruct.batchList = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'listbox', ...
+	'HorizontalAlignment','left', ...
+	'Units','points', ...
+	'Visible','on',...
+	'BackgroundColor', [1 1 1], ...
+	'Max', 1, ...
+	'Value', 1 , ...
+	'Enable', 'on', ...
+	'Position', batchListPos, ...
+	'Callback', 'view_ui batchlist', ...
+	'String', batchString, ...
+	'Tag', 'BatchListbox');
+
+%- Build About listbox
+aboutListPos = [200 220 340 180] * pixfactor;
+aboutString = ' ';
+handleStruct.aboutList = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'list', ...
+	'HorizontalAlignment','left', ...
+	'Units','points', ...
+	'Visible','on',...
+	'BackgroundColor', [0.8 0.8 0.8], ...
+	'Min', 0, ...
+	'Max', 2, ...
+	'Value', [], ...
+	'Enable', 'inactive', ...
+	'Position', aboutListPos, ...
+	'Callback', '', ...
+	'String', aboutString, ...
+	'Tag', 'AboutListbox');
+
+%- The Add button
+addBtnPos = [20 20 70 25] * pixfactor;
+handleStruct.add = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'pushbutton', ...
+	'Units', 'points', ...
+	'Position', addBtnPos, ...
+	'String', 'Add', ...
+   'Visible', 'on', ...
+   'Enable','on',...
+	'Tag', 'Add', ...
+	'Callback', 'view_ui add');
+	%'TooltipString', 'Add batch', ...
+   
+%- The modify button
+modifyBtnPos = [95 20 70 25] * pixfactor;
+handleStruct.modify = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'pushbutton', ...
+	'Units', 'points', ...
+	'Position', modifyBtnPos, ...
+	'String', 'Modify', ...
+   'Visible', 'on', ...
+   'Enable','on',...
+	'Tag', 'Modify', ...
+	'Callback', 'view_ui modify');
+	%'TooltipString', 'Modify batch', ...
+
+%- The Copy button
+copyBtnPos = [170 20 70 25] * pixfactor;
+handleStruct.copy = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'pushbutton', ...
+	'Units', 'points', ...
+	'Position', copyBtnPos, ...
+	'String', 'Copy', ...
+   'Visible', 'on', ...
+   'Enable','on',...
+	'Tag', 'Copy', ...
+	'Callback', 'view_ui copy');
+	%'TooltipString', 'Copy batch', ...
+
+%- The delete button
+deleteBtnPos = [245 20 70 25] * pixfactor;
+handleStruct.delete = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'pushbutton', ...
+	'Units', 'points', ...
+	'Position', deleteBtnPos, ...
+	'String', 'Delete', ...
+   'Visible', 'on', ...
+   'Enable','on',...
+	'Tag', 'Delete', ...
+	'Callback', 'view_ui delete');
+	%'TooltipString', 'Delete batch', ...
+
+%- The save button
+saveBtnPos = [320 20 70 25] * pixfactor;
+handleStruct.save = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'pushbutton', ...
+	'Units', 'points', ...
+	'Position', saveBtnPos, ...
+	'String', 'Save', ...
+   'Visible', 'on', ...
+   'UserData',0,...
+	'Tag', 'Save', ...
+	'Callback', 'view_ui save');
+	%'TooltipString', 'Save batch', ...
+
+%- The run button  
+runBtnPos = [395 20 70 25] * pixfactor;
+handleStruct.run = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'pushbutton', ...
+	'Units', 'points', ...
+	'Position', runBtnPos, ...
+	'String', 'Run', ...
+	'Visible', 'on', ...
+	'Enable', 'on', ...
+	'Tag', 'Run', ...
+	'Callback', 'view_ui run');
+	%'TooltipString', 'Run batch', ...
+
+%- The close button
+closeBtnPos = [470 20 70 25] * pixfactor;
+handleStruct.close = uicontrol( ...
+	'Parent',handleStruct.fig, ...
+	'Style', 'pushbutton', ...
+	'Units', 'points', ...
+	'Position', closeBtnPos, ...
+	'String', 'Close', ...
+	'Visible', 'on', ...
+	'Tag', 'Close', ...
+	'Callback', 'view_ui close');
+	%'TooltipString', 'Close window', ...
+
+handleArray = [handleStruct.fig handleStruct.batchList handleStruct.aboutList handleStruct.add handleStruct.modify handleStruct.copy handleStruct.delete handleStruct.save handleStruct.run handleStruct.close];
+
+set(handleArray,'Units', 'normalized');
Index: /trunk/src/@xmltree/xmltree.m
===================================================================
--- /trunk/src/@xmltree/xmltree.m	(revision 723)
+++ /trunk/src/@xmltree/xmltree.m	(revision 723)
@@ -0,0 +1,42 @@
+function tree = xmltree(varargin)
+% XMLTREE/XMLTREE Constructor of the XMLTree class
+% FORMAT tree = xmltree(varargin)
+% 
+% filename - XML filename
+% tree     - XMLTree Object
+%
+%     tree = xmltree;            % creates a minimal XML tree: <tag/>
+%     tree = xmltree(filename);  % creates a tree from an XML file
+%_______________________________________________________________________
+%
+% This is the constructor of the XMLTree class. 
+% It creates a tree of an XML 1.0 file (after parsing) that is stored 
+% using a Document Object Model (DOM) representation.
+% See http://www.w3.org/TR/REC-xml for details about XML 1.0.
+% See http://www.w3.org/DOM/ for details about DOM platform.
+%_______________________________________________________________________
+% @(#)xmltree.m                 Guillaume Flandin              02/03/27
+
+switch(nargin)
+	case 0
+		tree.tree{1} = struct('type','element',...
+		                      'name','tag',...
+						      'attributes',[],...
+						      'contents',[],...
+							  'parent',[],...
+						      'uid',1);
+		tree.filename = '';
+		tree = class(tree,'xmltree');
+	case 1
+		if isa(varargin{1},'xmltree')
+			tree = varargin{1};
+		elseif ischar(varargin{1})
+			tree.tree = xml_parser(varargin{1});
+			tree.filename = varargin{1};
+			tree = class(tree,'xmltree');
+		else 
+			error('[XMLTree] Bad input argument');
+		end
+	otherwise
+		error('[XMLTree] Bad number of arguments');
+end
