Index: trunk/src/@xmltree/private/xml_findstr.c
===================================================================
--- trunk/src/@xmltree/private/xml_findstr.c	(revision 723)
+++ trunk/src/@xmltree/private/xml_findstr.c	(revision 820)
Index: trunk/src/@xmltree/private/xml_findstr.m
===================================================================
--- trunk/src/@xmltree/private/xml_findstr.m	(revision 723)
+++ trunk/src/@xmltree/private/xml_findstr.m	(revision 820)
@@ -20,9 +20,23 @@
 %
 %   See also STRFIND, FINDSTR
+%_______________________________________________________________________
+% Copyright (C) 2002-2008  http://www.artefact.tk/
 
-%   Guillaume Flandin
-%   Copyright 2002 INRIA Sophia Antipolis
-%   $Revision: 1.0 $  $Date: 2002/04/10 22:50:32 $
-%   Implemented in a MATLAB mex file.
+% Guillaume Flandin <guillaume@artefact.tk>
+% $Id: xml_findstr.m 2271 2008-09-30 21:19:47Z guillaume $
 
-error(sprintf('Missing MEX-file: %s', mfilename));
+%error(sprintf('Missing MEX-file: %s', mfilename));
+
+persistent runonce
+if isempty(runonce)
+    warning(sprintf(['xml_findstr is not compiled for your platform.\n'...
+    'This will result in a slowdown of the XML parsing.']));
+    runonce = 1;
+end
+
+% k = regexp(s(i:end),p,'once') + i - 1;
+if nargin < 3, i = 1;   end
+if nargin < 4, n = Inf; end
+j = strfind(s,p);
+k = j(j>=i);
+if ~isempty(k), k = k(1:min(n,length(k))); end
Index: trunk/src/@xmltree/private/xml_parser.m
===================================================================
--- trunk/src/@xmltree/private/xml_parser.m	(revision 723)
+++ trunk/src/@xmltree/private/xml_parser.m	(revision 820)
@@ -1,8 +1,8 @@
-function tree = xml_parser(filename)
+function tree = xml_parser(xmlstr)
 % XML (eXtensible Markup Language) Processor
-% FORMAT tree = xml_parser(filename)
-%
-% filename - XML file to parse
-% tree     - tree structure corresponding to the XML file
+% FORMAT tree = xml_parser(xmlstr)
+%
+% xmlstr  - XML string to parse
+% tree    - tree structure corresponding to the XML file
 %_______________________________________________________________________
 %
@@ -10,13 +10,12 @@
 % written in Matlab. It aims to be fully conforming. It is currently not
 % a validating XML processor.
-% (based on a Javascript parser available at http://www.jeremie.com)
 %
 % A description of the tree structure provided in output is detailed in 
 % the header of this m-file.
 %_______________________________________________________________________
-% @(#)xml_parser.m               Guillaume Flandin           2002/04/04
+% @(#)xml_parser.m              Guillaume Flandin            2002/04/04
 
 % XML Processor for MATLAB (The Mathworks, Inc.).
-% Copyright (C) 2002  Guillaume Flandin
+% Copyright (C) 2002-2003 Guillaume Flandin <Guillaume@artefact.tk>
 %
 % This program is free software; you can redistribute it and/or
@@ -35,10 +34,13 @@
 %-----------------------------------------------------------------------
 
-% Please feel free to email the author any comment/suggestion/bug report
-% to improve this XML processor in Matlab.
-% Email: Guillaume.Flandin@sophia.inria.fr
+% Suggestions for improvement and fixes are always welcome, although no
+% guarantee is made whether and when they will be implemented.
+% Send requests to <Guillaume@artefact.tk>
 % Check also the latest developments on the following webpage:
-% http://www-sop.inria.fr/epidaure/personnel/flandin/xml/
-%-----------------------------------------------------------------------
+%           <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
@@ -92,13 +94,13 @@
 
 % TODO/BUG/FEATURES:
-%  - [compile] only a warning if TagStart is empty
+%  - [compile] only a warning if TagStart is empty ?
 %  - [attribution] should look for " and ' rather than only "
 %  - [main] with normalize as a preprocessing, CDATA are modified
 %  - [prolog] look for a DOCTYPE in the whole string even if it occurs
-%    only in a far CDATA tag (for example)...
+%    only in a far CDATA tag, bug even if the doctype is inside a comment
 %  - [tag_element] erode should replace normalize here
 %  - remove globals? uppercase globals  rather persistent (clear mfile)?
-%  - xml_findst is in fact xml_strfind according to Mathworks vocabulary
-%  - problem with entity (don't know if the bug is here or in save fct.)
+%  - xml_findstr is indeed xml_strfind according to Mathworks vocabulary
+%  - problem with entities: do we need to convert them here? (&eacute;)
 %-----------------------------------------------------------------------
 
@@ -108,17 +110,9 @@
 %- Check input arguments
 error(nargchk(1,1,nargin));
-if isempty(filename)
-	error('Not enough parameters.')
-elseif ~isstr(filename) | sum(size(filename)>1)>1
-	error('Input must be a string filename.')
+if isempty(xmlstr)
+	error('[XML] Not enough parameters.')
+elseif ~isstr(xmlstr) | sum(size(xmlstr)>1)>1
+	error('[XML] Input must be a string.')
 end
-
-%- Read the entire XML file
-fid = fopen(filename,'rt');
-if (fid==-1) 
-	error(sprintf('Cannot open %s for reading.',filename))
-end
-xmlstring = fscanf(fid,'%c');
-fclose(fid);
 
 %- Initialize number of tags (<=> uid)
@@ -126,5 +120,5 @@
 
 %- Remove prolog and white space characters from the XML string
-xmlstring = normalize(prolog(xmlstring));
+xmlstring = normalize(prolog(xmlstr));
 
 %- Initialize the XML tree
@@ -157,13 +151,12 @@
 		TagStart = xml_findstr(xmlstring,'<',frag.str,1);
 		if isempty(TagStart)
-			%- Character data (should be an error)
-			warning('[XML] Unknown data at the end of the XML file.');
-			fprintf('Please send me your XML file at gflandin@sophia.inria.fr\n');
-			%thisary = length(frag.ary) + 1;
-			xtree{Xparse_count+1} = chardata;
+			%- 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 = '';
+			frag.str = '';
 		elseif TagStart > frag.str
 			if strcmp(xmlstring(frag.str:TagStart-1),' ')
