[XML-SIG] Re: DOM notes, and xml.marshal module

Guido van Rossum guido@CNRI.Reston.Va.US
Mon, 20 Apr 1998 12:29:57 -0400

> 	* There's one problem with xml.marshal at the moment; you
> can't pickle multiple objects to the same stream because, when you
> read the data again, the parser doesn't read one data item and stop,
> but reads them all.
> 	For example, None is converted to a <none/> tag; if you pickle
> None to the same file object twice, you get <none/><none/>.  But when
> you parse this, the parser builds a tree containing both tags.  If an
> XML document must contain a single top-level element, then I think
> parsers should recognize when that top-level element has been
> completed and stop.
> 	Any thoughts on this question?  What's the correct behaviour?

The pickle module uses an explicit terminator symbol to end the
pickle.  The closest equivalent in XML is probably to define an extra
tag pair to surround the outermost thing, so you'd get
e.g. <pickle><none/></pickle><pickle><none/></pickle>.

If this doesn't work, you'll just have to be content that you can only 
pickle one item per file (this is how pickles are used 99% of the time 

--Guido van Rossum (home page: http://www.python.org/~guido/)