[XML-SIG] Parsing XML data from a stream where several XML elements follow?

Stephane Bortzmeyer bortzmeyer@nic.fr
Tue, 26 Nov 2002 16:25:38 +0100

I'm writing a simple XML Internet program which must be able to read
and parse successive XML elements coming on the same TCP stream (I did
not write the protocol so changing this is not an option).

If I write simple code like:

        read_channel = self.socket.makefile('r')
        reader = Sax2.Reader()
        reply = reader.fromStream(read_channel)

The fromStream method is stalled even after a complete XML element was
read because it waits for the channel to close. 

Is there a way to tell fromStream (which seems poorly documented) to
yield a result after the first complete element (or after a syntax
error)? Or is there a better way to read successive XML elements?