[XML-SIG] Parsing XML data from a stream where several XML elements follow?
Wed, 18 Dec 2002 10:07:49 +0100
On Tue, Nov 26, 2002 at 04:25:38PM +0100,
Stephane Bortzmeyer <email@example.com> wrote
a message of 20 lines which said:
> 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?
Well, apparently noone found a simple solution. I plan to SAX the
stream first to recognize the beginning and ending of the top-level
elements and then to hand them on to a DOM builder :-(