Index: /trunk/src/@xmltree/Contents.m
===================================================================
--- /trunk/src/@xmltree/Contents.m	(revision 924)
+++ /trunk/src/@xmltree/Contents.m	(revision 925)
@@ -1,4 +1,4 @@
-% XMLTree: XML Toolbox for Matlab.
-% Version 1.2  17-Nov-2004
+% XMLTree: XML Toolbox for MATLAB and GNU Octave
+% Version 2.0  14-Aug-2015
 %
 % XML file I/O.
@@ -11,5 +11,5 @@
 %   branch      - Extract a subtree from a tree.
 %   children    - Return children of a node.
-%   convert     - Convert a tree in a Matlab structure.
+%   convert     - Convert a tree in a MATLAB structure.
 %   copy        - Copy nodes within a tree.
 %   delete      - Delete a node in a tree.
@@ -24,20 +24,18 @@
 %   root        - Return the root element of a tree.
 %   set         - Set node properties.
-%   setfilename - Set filename
+%   setfilename - Set filename.
 %
-% Graphical user interface methods (work in progress).
-%   editor      - Reimplementation of <view> for Matlab 6+
-%   view        - Graphical display of a tree.
-%   view_ui     - Useful function for view method.
+% Graphical user interface methods (basic).
+%   editor      - Graphical display of a tree.
 %
 % Low level class methods.
 %   char        - Convert a tree into a string (for display).
-%   display     - Display a tree into MATLAB.
+%   display     - Display a tree in the workspace.
 %
 % Private methods.
 %   xml_parser  - XML parser.
-%   xml_findstr - Find one string within another (mexfile)
+%   xml_findstr - Find one string within another (C-MEX file).
 %
-% Conversions Matlab <=> XML
+% Conversions struct <=> XML.
 %   loadxml     - 
 %   savexml     - 
@@ -51,4 +49,6 @@
 %   xmldemo3    - Read an XML file, modify some fields and save it.
 
-% Copyright 2002-2004 Guillaume Flandin <Guillaume@artefact.tk>
-% $Revision: 1.2 $
+% Copyright 2002-2015  http://www.artefact.tk/
+
+% Guillaume Flandin <Guillaume@artefact.tk>
+% $Id: Contents.m 6480 2015-06-13 01:08:30Z guillaume $
Index: /trunk/src/@xmltree/add.m
===================================================================
--- /trunk/src/@xmltree/add.m	(revision 924)
+++ /trunk/src/@xmltree/add.m	(revision 925)
@@ -13,5 +13,5 @@
 %        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.
@@ -20,72 +20,74 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(4,4,nargin));
+% Guillaume Flandin
+% $Id: add.m 4460 2011-09-05 14:52:16Z guillaume $
+
 
 if ~isa(uid,'double')
-	error('[XMLTree] UID must be a double array.');
+    error('[XMLTree] UID must be a double array.');
 end
 if ~ischar(type)
-	error('[XMLTree] TYPE must be a valid item 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
+    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.');
+    error('[XMLTree] PARAMETER must be a string.');
 end
 
 if nargout == 2
-	l = length(tree.tree);
-	varargout{2} = (l+1):(l+prod(size(uid)));
+    l = length(tree.tree);
+    varargout{2} = (l+1):(l+numel(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);
+for i=1:numel(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
 
Index: /trunk/src/@xmltree/attributes.m
===================================================================
--- /trunk/src/@xmltree/attributes.m	(revision 924)
+++ /trunk/src/@xmltree/attributes.m	(revision 925)
@@ -13,100 +13,105 @@
 %
 %     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)
-%_______________________________________________________________________
+%     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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(3,6,nargin));
+% Guillaume Flandin
+% $Id: attributes.m 4460 2011-09-05 14:52:16Z guillaume $
+
+
+%error(nargchk(3,6,nargin));
+
 tree = varargin{1};
-if ~ischar(varargin{2}) | ...
+if ~ischar(varargin{2}) || ...
    ~any(strcmp(varargin{2},{'set','get','add','del','length'}))
-	error('[XMLTree] Unknown method.');
+    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.');
+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.');
+    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 ischar(varargin{4})
-				for i=1:length(tree.tree{uid}.attributes)
-					if strcmp(varargin{4},tree.tree{uid}.attributes{i}.key)
-						varargout{1} = tree.tree{uid}.attributes{i}.val;
-						return;
-					end
-				end
-				varargout{1} = [];
-			elseif ~isa(varargin{4},'double') | ...
-			   any(varargin{4}>length(tree.tree{uid}.attributes)) | ...
-			   any(varargin{4}<1)
-				error('[XMLTree] Invalid attribute indice.');
-			else
-				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
-			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.');
+    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 ischar(varargin{4})
+                for i=1:length(tree.tree{uid}.attributes)
+                    if strcmp(varargin{4},tree.tree{uid}.attributes{i}.key)
+                        varargout{1} = tree.tree{uid}.attributes{i}.val;
+                        return;
+                    end
+                end
+                varargout{1} = [];
+            elseif ~isa(varargin{4},'double') || ...
+               any(varargin{4}>length(tree.tree{uid}.attributes)) || ...
+               any(varargin{4}<1)
+                error('[XMLTree] Invalid attribute indice.');
+            else
+                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
+            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 924)
+++ /trunk/src/@xmltree/branch.m	(revision 925)
@@ -6,16 +6,20 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(2,2,nargin));
+% Guillaume Flandin
+% $Id: branch.m 4460 2011-09-05 14:52:16Z guillaume $
 
-if uid > length(tree) | ...
-   prod(size(uid))~=1 | ...
+
+%error(nargchk(2,2,nargin));
+
+if uid > length(tree) || ...
+   numel(uid)~=1 || ...
    ~strcmp(tree.tree{uid}.type,'element')
-	error('[XMLTree] Invalid UID.');
+    error('[XMLTree] Invalid UID.');
 end
 
@@ -28,24 +32,24 @@
 
 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];
+    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
+    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 924)
+++ /trunk/src/@xmltree/char.m	(revision 925)
@@ -5,10 +5,14 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: char.m 4460 2011-09-05 14:52:16Z guillaume $
+
 
 s = strcat('XMLTree object (',num2str(length(tree)),' nodes) [',getfilename(tree),']');
Index: /trunk/src/@xmltree/children.m
===================================================================
--- /trunk/src/@xmltree/children.m	(revision 924)
+++ /trunk/src/@xmltree/children.m	(revision 925)
@@ -6,11 +6,14 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(2,2,nargin));
+% Guillaume Flandin
+% $Id: children.m 4460 2011-09-05 14:52:16Z guillaume $
+
+%error(nargchk(2,2,nargin));
 
 child = [];
@@ -18,11 +21,11 @@
 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
+    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 924)
+++ /trunk/src/@xmltree/convert.m	(revision 925)
@@ -1,4 +1,4 @@
 function s = convert(tree,uid)
-% XMLTREE/CONVERT Converter an XML tree in a Matlab structure
+% XMLTREE/CONVERT Converter an XML tree in a structure
 % 
 % tree      - XMLTree object
@@ -6,28 +6,31 @@
 %             Default is root
 % s         - converted structure
-%_______________________________________________________________________
+%__________________________________________________________________________
 %
-% Convert an xmltree into a Matlab structure, when possible.
+% Convert an XMLTree into a 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2015  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: convert.m 6480 2015-06-13 01:08:30Z guillaume $
 
 % Exemple:
-% tree: <toto><titi>field1</titi><tutu>field2</tutu><titi>field3</titi></toto>
-% toto = convert(tree);
-% <=> toto = struct('titi',{{'field1', 'field3'}},'tutu','field2')
+% tree = '<a><b>field1</b><c>field2</c><b>field3</b></a>';
+% toto = convert(xmltree(tree));
+% <=> toto = struct('b',{{'field1', 'field3'}},'c','field2')
 
-error(nargchk(1,2,nargin));
+%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);
+    % Get the root uid of the XML tree
+    root_uid = root(tree);
 else
-	% Uid provided by user
-	root_uid = uid;
+    % Uid provided by user
+    root_uid = uid;
 end
 
@@ -43,36 +46,36 @@
 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
+    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
             %- saving attributes : does not work with <a t='q'>b</a>
             %- but ok with <a t='q'><c>b</c></a>
@@ -81,44 +84,44 @@
 %                 arg2 = {arg{:} 'attributes'};       %-
 %                 s = sub_setfield(s,arg2{:},attrb);  %-
-% 			  end                                     %-
-		case 'chardata'
-			s = sub_setfield(s,arg{:},get(tree,uid,'value'));
-			%- convert strings into their Matlab equivalent when possible
-			%- e.g. string '3.14159' becomes double scalar 3.14159
+%             end                                     %-
+        case 'chardata'
+            s = sub_setfield(s,arg{:},get(tree,uid,'value'));
+            %- convert strings into their numerical equivalent when possible
+            %- e.g. string '3.14159' becomes double scalar 3.14159
 %             v = get(tree,uid,'value');              %-
-% 		 	  cv = str2num(v);                        %-
-% 			  if isempty(cv)                          %-
-% 				  s = sub_setfield(s,arg{:},v);       %-
-% 			  else                                    %-
-% 				  s = sub_setfield(s,arg{:},cv);      %-
+%             cv = str2num(v);                        %-
+%             if isempty(cv)                          %-
+%                 s = sub_setfield(s,arg{:},v);       %-
+%             else                                    %-
+%                 s = sub_setfield(s,arg{:},cv);      %-
 %             end                                     %-
-		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] Unknown target application');
-					end
-			end
-		case 'comment'
-			% Comments are forgotten
-		otherwise
-			warning(sprintf('Type %s unknown : not saved',get(tree,uid,'type')));
-	end
-	
-%=======================================================================
+        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] 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 '()'
@@ -131,5 +134,5 @@
     if (isa(varargin{i}, 'cell'))
         types{i} = '{}';
-    elseif isstr(varargin{i})
+    elseif ischar(varargin{i})
         types{i} = '.';
         subs{i} = varargin{i}; %strrep(varargin{i},' ',''); % deblank field name
Index: /trunk/src/@xmltree/copy.m
===================================================================
--- /trunk/src/@xmltree/copy.m	(revision 924)
+++ /trunk/src/@xmltree/copy.m	(revision 925)
@@ -6,14 +6,19 @@
 % 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
+% Copy a subtree to another branch.
+% The tree parameter must be in input AND in output.
+%__________________________________________________________________________
+% Copyright (C) 2002-2015  http://www.artefact.tk/
 
-error(nargchk(2,3,nargin));
+% Guillaume Flandin
+% $Id: copy.m 6480 2015-06-13 01:08:30Z guillaume $
+
+
+%error(nargchk(2,3,nargin));
+
 if nargin == 2
-	uid = parent(tree,subuid);
+    uid = parent(tree,subuid);
 end
 
@@ -22,24 +27,24 @@
 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 ?
+% to have the copy next to the original and not at the end?
 %  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
+    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 924)
+++ /trunk/src/@xmltree/delete.m	(revision 925)
@@ -4,30 +4,33 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(2,2,nargin));
+% Guillaume Flandin
+% $Id: delete.m 4460 2011-09-05 14:52:16Z guillaume $
+
+%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
+    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');
+    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 924)
+++ /trunk/src/@xmltree/display.m	(revision 925)
@@ -4,16 +4,19 @@
 % 
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: display.m 4460 2011-09-05 14:52:16Z guillaume $
 
 disp(' ');
 disp([inputname(1),' = ']);
 disp(' ');
-for i=1:prod(size(tree))
-	disp([blanks(length(inputname(1))+3) char(tree(i))]);
+for i=1:numel(tree)
+    disp([blanks(length(inputname(1))+3) char(tree(i))]);
 end
 disp(' ');
Index: /trunk/src/@xmltree/find.m
===================================================================
--- /trunk/src/@xmltree/find.m	(revision 924)
+++ /trunk/src/@xmltree/find.m	(revision 925)
@@ -16,10 +16,13 @@
 %        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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: find.m 4460 2011-09-05 14:52:16Z guillaume $
 
 % TODO:
@@ -30,53 +33,53 @@
 
 if nargin==0
-	error('[XMLTree] A tree must be provided');
+    error('[XMLTree] A tree must be provided');
 elseif nargin==1
-	list = 1:length(tree.tree);
-	return
+    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{:});
+    list = sub_find_subtree1(varargin{1}.tree,root(varargin{1}),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
+    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
+    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,
+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
 
@@ -85,87 +88,87 @@
 %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
+%     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
-	
-%=======================================================================
+    %- Search for the delimiter '/' in the path
+    i = strfind(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
+    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 924)
+++ /trunk/src/@xmltree/flush.m	(revision 925)
@@ -5,35 +5,39 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(1,2,nargin));
+% Guillaume Flandin
+% $Id: flush.m 4460 2011-09-05 14:52:16Z guillaume $
+
+
+%error(nargchk(1,2,nargin));
 
 if nargin == 1,
-	uid = root(tree);
+    uid = root(tree);
 end
 
 uid = uid(:);
 for i=1:length(uid)
-	 tree = sub_flush(tree,uid(i));
+     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
+    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 924)
+++ /trunk/src/@xmltree/get.m	(revision 925)
@@ -7,33 +7,37 @@
 % parameter - property name
 % value     - property value
-%_______________________________________________________________________
+%__________________________________________________________________________
 %
 % Get object properties of a tree given their UIDs.
-%_______________________________________________________________________
-% @(#)get.m                   Guillaume Flandin                02/03/27
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(2,3,nargin));
+% Guillaume Flandin
+% $Id: get.m 4460 2011-09-05 14:52:16Z guillaume $
+
+
+%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
+    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 
+    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};
+    value = value{1};
 end  
Index: /trunk/src/@xmltree/getfilename.m
===================================================================
--- /trunk/src/@xmltree/getfilename.m	(revision 924)
+++ /trunk/src/@xmltree/getfilename.m	(revision 925)
@@ -5,10 +5,13 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: getfilename.m 4460 2011-09-05 14:52:16Z guillaume $
 
 filename = tree.filename;
Index: /trunk/src/@xmltree/isfield.m
===================================================================
--- /trunk/src/@xmltree/isfield.m	(revision 924)
+++ /trunk/src/@xmltree/isfield.m	(revision 925)
@@ -7,16 +7,20 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(3,3,nargin));
+% Guillaume Flandin
+% $Id: isfield.m 4460 2011-09-05 14:52:16Z guillaume $
+
+
+%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
+    if isfield(tree.tree{uid(i)},parameter)
+        F(i) = 1;
+    end
 end
Index: /trunk/src/@xmltree/length.m
===================================================================
--- /trunk/src/@xmltree/length.m	(revision 924)
+++ /trunk/src/@xmltree/length.m	(revision 925)
@@ -7,11 +7,15 @@
 %         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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(1,2,nargin));
+% Guillaume Flandin
+% $Id: length.m 4460 2011-09-05 14:52:16Z guillaume $
+
+
+%error(nargchk(1,2,nargin));
 
 % Return the full number of nodes once allocated
@@ -20,14 +24,14 @@
 % 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
+    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 924)
+++ /trunk/src/@xmltree/move.m	(revision 925)
@@ -5,12 +5,16 @@
 % 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
+% The tree parameter must be in input AND in output.
+%__________________________________________________________________________
+% Copyright (C) 2002-2015  http://www.artefact.tk/
 
-error(nargchk(3,3,nargin));
+% Guillaume Flandin
+% $Id: move.m 6480 2015-06-13 01:08:30Z guillaume $
+
+
+%error(nargchk(3,3,nargin));
 
 p = tree.tree{uida}.parent;
Index: /trunk/src/@xmltree/parent.m
===================================================================
--- /trunk/src/@xmltree/parent.m	(revision 924)
+++ /trunk/src/@xmltree/parent.m	(revision 925)
@@ -6,9 +6,12 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: parent.m 4460 2011-09-05 14:52:16Z guillaume $
 
 p = tree.tree{uid}.parent;
Index: /trunk/src/@xmltree/private/xml_findstr.c
===================================================================
--- /trunk/src/@xmltree/private/xml_findstr.c	(revision 924)
+++ /trunk/src/@xmltree/private/xml_findstr.c	(revision 925)
@@ -2,18 +2,25 @@
 
 /*
-    Differences with matlab built-in findstr:
+ * $Id: xml_findstr.c 6480 2015-06-13 01:08:30Z guillaume $
+ * Guillaume Flandin <guillaume@artefact.tk>
+ */
+
+/*
+    Differences with 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:
+    MATLAB hack:
         - doesn't use mxGetString to prevent a copy of the string.
-        - assumes Matlab stores strings as unsigned short (Unicode 16 bits)
+        - 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)
+          (that's the case for MATLAB 5.*, 6.* and 7.* but MATLAB 4.* stores
+           strings as double and GNU Octave as char, see src/mxarray.h)
 */
 
 /* Comment the following line to use standard mxGetString (slower) */
+#if !defined (HAVE_OCTAVE)
 #define __HACK_MXCHAR__
+#endif
 
 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
@@ -28,18 +35,18 @@
     mxArray *out = NULL;
     
-	/* Check for proper number of arguments. */
+    /* Check for proper number of arguments. */
     if ((nrhs == 0) || (nrhs == 1))
-	    mexErrMsgTxt("Not enough input arguments.");
+        mexErrMsgTxt("Not enough input arguments.");
     else if (nrhs > 4)
-	    mexErrMsgTxt("Too many input arguments.");
+        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]);
+    if (!mxIsChar(prhs[0]))
+        mexErrMsgTxt("Inputs must be character arrays.");
+    stext = mxGetM(prhs[0]) * mxGetN(prhs[0]);
 #ifdef __HACK_MXCHAR__
-	text = mxGetData(prhs[0]);
+    text = mxGetData(prhs[0]);
 #else
     text = mxCalloc(stext+1, sizeof(char));
@@ -48,31 +55,31 @@
         
     /* The input PATTERN must be a string */
-	if (!mxIsChar(prhs[1]))
-		mexErrMsgTxt("Inputs must be character arrays.");
+    if (!mxIsChar(prhs[1]))
+        mexErrMsgTxt("Inputs must be character arrays.");
     spattern = mxGetM(prhs[1]) * mxGetN(prhs[1]);
 #ifdef __HACK_MXCHAR__
-	pattern = mxGetData(prhs[1]);
+    pattern = mxGetData(prhs[1]);
 #else
     pattern = mxCalloc(spattern+1, sizeof(char));
-	mxGetString(prhs[1], pattern, spattern+1);
+    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 */
+    /* 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++) {
Index: /trunk/src/@xmltree/private/xml_findstr.m
===================================================================
--- /trunk/src/@xmltree/private/xml_findstr.m	(revision 924)
+++ /trunk/src/@xmltree/private/xml_findstr.m	(revision 925)
@@ -20,9 +20,9 @@
 %
 %   See also STRFIND, FINDSTR
-%_______________________________________________________________________
-% Copyright (C) 2002-2008  http://www.artefact.tk/
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-% Guillaume Flandin <guillaume@artefact.tk>
-% $Id: xml_findstr.m 2271 2008-09-30 21:19:47Z guillaume $
+% Guillaume Flandin
+% $Id: xml_findstr.m 4460 2011-09-05 14:52:16Z guillaume $
 
 %error(sprintf('Missing MEX-file: %s', mfilename));
Index: /trunk/src/@xmltree/private/xml_parser.m
===================================================================
--- /trunk/src/@xmltree/private/xml_parser.m	(revision 924)
+++ /trunk/src/@xmltree/private/xml_parser.m	(revision 925)
@@ -5,17 +5,20 @@
 % xmlstr  - XML string 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.
+%__________________________________________________________________________
+%
+% xml_parser.m is an XML 1.0 (http://www.w3.org/TR/REC-xml) parser.
+% It aims to be fully conforming. It is currently not a validating 
+% XML processor.
 %
 % 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-2003 Guillaume Flandin <Guillaume@artefact.tk>
+%__________________________________________________________________________
+% Copyright (C) 2002-2015  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: xml_parser.m 6480 2015-06-13 01:08:30Z guillaume $
+
+% XML Processor for GNU Octave and MATLAB (The Mathworks, Inc.)
+% Copyright (C) 2002-2015 Guillaume Flandin <Guillaume@artefact.tk>
 %
 % This program is free software; you can redistribute it and/or
@@ -32,5 +35,5 @@
 % along with this program; if not, write to the Free Software
 % Foundation Inc, 59 Temple Pl. - Suite 330, Boston, MA 02111-1307, USA.
-%-----------------------------------------------------------------------
+%--------------------------------------------------------------------------
 
 % Suggestions for improvement and fixes are always welcome, although no
@@ -39,16 +42,16 @@
 % Check also the latest developments on the following webpage:
 %           <http://www.artefact.tk/software/matlab/xml/>
-%-----------------------------------------------------------------------
+%--------------------------------------------------------------------------
 
 % The implementation of this XML parser is much inspired from a 
-% Javascript parser available at <http://www.jeremie.com/>
-
-% A mex-file xml_findstr.c is also required, to encompass some
-% limitations of the built-in findstr Matlab function.
+% Javascript parser that used to be available at <http://www.jeremie.com/>
+
+% A C-MEX file xml_findstr.c is also required, to encompass some
+% limitations of the built-in FINDSTR 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.
-%-----------------------------------------------------------------------
+% If this function does not behave as expected, comment the line
+% '#define __HACK_MXCHAR__' in xml_findstr.c and compile it again.
+%--------------------------------------------------------------------------
 
 % Structure of the output tree:
@@ -91,5 +94,5 @@
 %       |_ uid:    double
 %
-%-----------------------------------------------------------------------
+%--------------------------------------------------------------------------
 
 % TODO/BUG/FEATURES:
@@ -103,5 +106,5 @@
 %  - xml_findstr is indeed xml_strfind according to Mathworks vocabulary
 %  - problem with entities: do we need to convert them here? (&eacute;)
-%-----------------------------------------------------------------------
+%--------------------------------------------------------------------------
 
 %- XML string to parse and number of tags read
@@ -109,9 +112,9 @@
 
 %- Check input arguments
-error(nargchk(1,1,nargin));
+%error(nargchk(1,1,nargin));
 if isempty(xmlstr)
-	error('[XML] Not enough parameters.')
-elseif ~isstr(xmlstr) | sum(size(xmlstr)>1)>1
-	error('[XML] Input must be a string.')
+    error('[XML] Not enough parameters.')
+elseif ~ischar(xmlstr) || sum(size(xmlstr)>1)>1
+    error('[XML] Input must be a string.')
 end
 
@@ -137,285 +140,282 @@
 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
-			error(sprintf(['[XML] Unknown data at the end of the XML file.\n' ...
-			'      Please send me your XML file at Guillaume@artefact.tk']));
-			xtree{Xparse_count} = 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
-
-%-----------------------------------------------------------------------
+    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
+            error('[XML] Unknown data at the end of the XML file.');
+            Xparse_count = Xparse_count + 1;
+            xtree{Xparse_count} = 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
+                Xparse_count = Xparse_count + 1;
+                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
-
-%-----------------------------------------------------------------------
+    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
+        Xparse_count = Xparse_count + 1;
+        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 ~isempty(attribs)
+            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
-
-%-----------------------------------------------------------------------
+    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);
+        Xparse_count = Xparse_count + 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
-
-%-----------------------------------------------------------------------
+    global xmlstring xtree Xparse_count;
+    close = xml_findstr(xmlstring,'-->',frag.str,1);
+    if isempty(close)
+        warning('[XML] Tag <!-- opened but not closed.')
+    else
+        Xparse_count = Xparse_count + 1;
+        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
-
-%-----------------------------------------------------------------------
+    global xmlstring xtree Xparse_count;
+    close = xml_findstr(xmlstring,']]>',frag.str,1);
+    if isempty(close)
+        warning('[XML] Tag <![CDATA[ opened but not closed.')
+    else
+        Xparse_count = Xparse_count + 1;
+        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
-
-%-----------------------------------------------------------------------
+    %- 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 = sort([xml_findstr(str,'"',1,1),xml_findstr(str,'''',1,1)]); id=id(1);
+        nextid = sort([xml_findstr(str,'"',id+1,1),xml_findstr(str,'''',id+1,1)]);nextid=nextid(1);
+        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);
+    global Xparse_count;
+    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);
+    global Xparse_count;
+    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);
+    global Xparse_count;
+    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);
-
-%-----------------------------------------------------------------------
+    global Xparse_count;
+    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);
-
-%-----------------------------------------------------------------------
+    global Xparse_count;
+    commt = struct('type','comment','value','','parent',[],'uid',Xparse_count);
+
+%--------------------------------------------------------------------------
 function frg = fragment
-	frg = struct('str','','parent','','end','');
-
-%-----------------------------------------------------------------------
+    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);
-
-%-----------------------------------------------------------------------
+    %- 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 strcmpi(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) = '';
-
-%-----------------------------------------------------------------------
+    str(isspace(str)) = '';
+
+%--------------------------------------------------------------------------
 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
-
-%-----------------------------------------------------------------------
+    % 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)];
+        str(i(j == -1)) = [];
+    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;','&');
+    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;
+    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 924)
+++ /trunk/src/@xmltree/root.m	(revision 925)
@@ -5,9 +5,12 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2008  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: root.m 4460 2011-09-05 14:52:16Z guillaume $
 
 % Actually root is necessarily the element whos UID is 1, by
@@ -27,7 +30,7 @@
 % 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
+    if strcmp(get(tree,i,'type'),'element')
+        uid = i;
+        break
+    end
 end
Index: /trunk/src/@xmltree/save.m
===================================================================
--- /trunk/src/@xmltree/save.m	(revision 924)
+++ /trunk/src/@xmltree/save.m	(revision 925)
@@ -6,12 +6,16 @@
 % filename  - XML output filename
 % varargout - XML string
-%_______________________________________________________________________
+%__________________________________________________________________________
 %
 % Convert an XML tree into a well-formed XML string and write it into
 % a file or return it as a string if no filename is provided.
-%_______________________________________________________________________
-% @(#)save.m                 Guillaume Flandin                 01/07/11
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(1,2,nargin));
+% Guillaume Flandin
+% $Id: save.m 4460 2011-09-05 14:52:16Z guillaume $
+
+
+%error(nargchk(1,2,nargin));
 
 prolog = '<?xml version="1.0" ?>\n';
@@ -19,112 +23,113 @@
 %- Return the XML tree as a string
 if nargin == 1
-	varargout{1} = [sprintf(prolog) ...
-		print_subtree(tree,'',root(tree))];
+    varargout{1} = [sprintf(prolog) ...
+        print_subtree(tree,'',root(tree))];
 %- Output specified
 else
-	%- 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 = ''; %- With this option, do not write any prolog
-	else
-		error('[XMLTree] Invalid argument.');
-	end
-	fprintf(fid,prolog);
-	save_subtree(tree,fid,root(tree));
-	if isstr(filename), fclose(fid); end
-	if nargout == 1
-		varargout{1} = print_subtree(tree,'',root(tree));
-	end
+    %- Filename provided
+    if ischar(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) && numel(filename) == 1
+        fid = filename;
+        prolog = ''; %- With this option, do not write any prolog
+    else
+        error('[XMLTree] Invalid argument.');
+    end
+    fprintf(fid,prolog);
+    save_subtree(tree,fid,root(tree));
+    if ischar(filename), fclose(fid); end
+    if nargout == 1
+        varargout{1} = print_subtree(tree,'',root(tree));
+    end
 end
 
-%=======================================================================
+%==========================================================================
 function xmlstr = print_subtree(tree,xmlstr,uid,order)
-	if nargin < 4, order = 0; end
-	xmlstr = [xmlstr blanks(3*order)];
-	switch tree.tree{uid}.type
-		case 'element'
-			xmlstr = sprintf('%s<%s',xmlstr,tree.tree{uid}.name);
-			for i=1:length(tree.tree{uid}.attributes)
-				xmlstr = sprintf('%s %s="%s"', xmlstr, ...
-					tree.tree{uid}.attributes{i}.key,...
-					tree.tree{uid}.attributes{i}.val);
-			end
-			if isempty(tree.tree{uid}.contents)
-				xmlstr = sprintf('%s/>\n',xmlstr);
-			else
-				xmlstr = sprintf('%s>\n',xmlstr);
-				for i=1:length(tree.tree{uid}.contents)
-					xmlstr = print_subtree(tree,xmlstr, ...
-						tree.tree{uid}.contents(i),order+1);
-  				end
-				xmlstr = [xmlstr blanks(3*order)];
-				xmlstr = sprintf('%s</%s>\n',xmlstr,...
-					tree.tree{uid}.name);
-			end
-		case 'chardata'
-			xmlstr = sprintf('%s%s\n',xmlstr, ...
-				entity(tree.tree{uid}.value));
-		case 'cdata'
-			xmlstr = sprintf('%s<![CDATA[%s]]>\n',xmlstr, ...
-				tree.tree{uid}.value);
-		case 'pi'
-			xmlstr = sprintf('%s<?%s %s?>\n',xmlstr, ...
-				tree.tree{uid}.target, tree.tree{uid}.value);
-		case 'comment'
-			xmlstr = sprintf('%s<!-- %s -->\n',xmlstr,...
-				tree.tree{uid}.value);
-		otherwise
-			warning(sprintf('Type %s unknown: not saved', ...
-				tree.tree{uid}.type));
-	end
+    if nargin < 4, order = 0; end
+    xmlstr = [xmlstr blanks(3*order)];
+    switch tree.tree{uid}.type
+        case 'element'
+            xmlstr = sprintf('%s<%s',xmlstr,tree.tree{uid}.name);
+            for i=1:length(tree.tree{uid}.attributes)
+                xmlstr = sprintf('%s %s="%s"', xmlstr, ...
+                    tree.tree{uid}.attributes{i}.key,...
+                    tree.tree{uid}.attributes{i}.val);
+            end
+            if isempty(tree.tree{uid}.contents)
+                xmlstr = sprintf('%s/>\n',xmlstr);
+            else
+                xmlstr = sprintf('%s>\n',xmlstr);
+                for i=1:length(tree.tree{uid}.contents)
+                    xmlstr = print_subtree(tree,xmlstr, ...
+                        tree.tree{uid}.contents(i),order+1);
+                end
+                xmlstr = [xmlstr blanks(3*order)];
+                xmlstr = sprintf('%s</%s>\n',xmlstr,...
+                    tree.tree{uid}.name);
+            end
+        case 'chardata'
+            xmlstr = sprintf('%s%s\n',xmlstr, ...
+                entity(tree.tree{uid}.value));
+        case 'cdata'
+            xmlstr = sprintf('%s<![CDATA[%s]]>\n',xmlstr, ...
+                tree.tree{uid}.value);
+        case 'pi'
+            xmlstr = sprintf('%s<?%s %s?>\n',xmlstr, ...
+                tree.tree{uid}.target, tree.tree{uid}.value);
+        case 'comment'
+            xmlstr = sprintf('%s<!-- %s -->\n',xmlstr,...
+                tree.tree{uid}.value);
+        otherwise
+            warning(sprintf('Type %s unknown: not saved', ...
+                tree.tree{uid}.type));
+    end
 
-%=======================================================================
+%==========================================================================
 function save_subtree(tree,fid,uid,order)
-	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
-			if isempty(tree.tree{uid}.contents)
-				fprintf(fid,'/>\n');
-			else
-				fprintf(fid,'>\n');
-				for i=1:length(tree.tree{uid}.contents)
-					save_subtree(tree,fid,...
-						tree.tree{uid}.contents(i),order+1)
-  				end
-				fprintf(fid,blanks(3*order));
-				fprintf(fid,'</%s>\n',tree.tree{uid}.name);
-			end
-		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('[XMLTree] Type %s unknown: not saved', ...
-				tree.tree{uid}.type));
-	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
+            if isempty(tree.tree{uid}.contents)
+                fprintf(fid,'/>\n');
+            else
+                fprintf(fid,'>\n');
+                for i=1:length(tree.tree{uid}.contents)
+                    save_subtree(tree,fid,...
+                        tree.tree{uid}.contents(i),order+1)
+                end
+                fprintf(fid,blanks(3*order));
+                fprintf(fid,'</%s>\n',tree.tree{uid}.name);
+            end
+        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('[XMLTree] 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;');
+    % This has the side effect of strtrim'ming the char array.
+    str = char(strrep(cellstr(str), '&',  '&amp;' ));
+    str = char(strrep(cellstr(str), '<',  '&lt;'  ));
+    str = char(strrep(cellstr(str), '>',  '&gt;'  ));
+    str = char(strrep(cellstr(str), '"',  '&quot;'));
+    str = char(strrep(cellstr(str), '''', '&apos;'));
Index: /trunk/src/@xmltree/set.m
===================================================================
--- /trunk/src/@xmltree/set.m	(revision 924)
+++ /trunk/src/@xmltree/set.m	(revision 925)
@@ -7,17 +7,21 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
 
-error(nargchk(4,4,nargin));
+% Guillaume Flandin
+% $Id: set.m 4460 2011-09-05 14:52:16Z guillaume $
+
+
+%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);
+    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 924)
+++ /trunk/src/@xmltree/setfilename.m	(revision 925)
@@ -5,9 +5,12 @@
 % tree     - XMLTree object
 % filename - XML filename
-%_______________________________________________________________________
+%__________________________________________________________________________
 %
 % Set the filename linked to the XML tree as filename.
-%_______________________________________________________________________
-% @(#)setfilename.m               Guillaume Flandin            02/03/27
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: setfilename.m 4460 2011-09-05 14:52:16Z guillaume $
 
 tree.filename = filename;
Index: /trunk/src/@xmltree/xmltree.m
===================================================================
--- /trunk/src/@xmltree/xmltree.m	(revision 924)
+++ /trunk/src/@xmltree/xmltree.m	(revision 925)
@@ -9,5 +9,5 @@
 %     tree = xmltree('foo.xml');  % creates a tree from XML file 'foo.xml'
 %     tree = xmltree('<tag>content</tag>') % creates a tree from string
-%_______________________________________________________________________
+%__________________________________________________________________________
 %
 % This is the constructor of the XMLTree class. 
@@ -16,42 +16,46 @@
 % 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
+%__________________________________________________________________________
+% Copyright (C) 2002-2011  http://www.artefact.tk/
+
+% Guillaume Flandin
+% $Id: xmltree.m 4460 2011-09-05 14:52:16Z guillaume $
 
 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})
-			% Input argument is an XML string
-			if (exist(varargin{1}) ~= 2 & ...
-				~isempty(xml_findstr(varargin{1},'<',1,1)))
-				tree.tree = xml_parser(varargin{1});
-				tree.filename = '';
-			% Input argument is an XML filename
-			else
-				fid = fopen(varargin{1},'rt');
-				if (fid == -1) 
-					error(['[XMLTree] Cannot open ' varargin{1}]);
-				end
-				xmlstr = fscanf(fid,'%c');
-				fclose(fid);
-				tree.tree = xml_parser(xmlstr);
-				tree.filename = varargin{1};
-			end
-			tree = class(tree,'xmltree');
-		else 
-			error('[XMLTree] Bad input argument');
-		end
-	otherwise
-		error('[XMLTree] Too many input arguments');
+    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})
+            % Input argument is an XML string
+            if (~exist(varargin{1},'file') && ...
+                ~isempty(xml_findstr(varargin{1},'<',1,1)))
+                tree.tree = xml_parser(varargin{1});
+                tree.filename = '';
+            % Input argument is an XML filename
+            else
+                fid = fopen(varargin{1},'rt');
+                if (fid == -1) 
+                    error(['[XMLTree] Cannot open ' varargin{1}]);
+                end
+                xmlstr = fread(fid,'*char')';
+                %xmlstr = fscanf(fid,'%c');
+                fclose(fid);
+                tree.tree = xml_parser(xmlstr);
+                tree.filename = varargin{1};
+            end
+            tree = class(tree,'xmltree');
+        else 
+            error('[XMLTree] Bad input argument');
+        end
+    otherwise
+        error('[XMLTree] Too many input arguments');
 end
