bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Incremental XML Parsing


From: Ari Johnson
Subject: Incremental XML Parsing
Date: Tue, 8 Oct 2002 22:37:50 -0500 (CDT)

Has anyone written code to allow incremental XML parsing?  There are two
ways that this could be done, and actually I feel that both should be
available.  They both require using libxml's xmlCreatePushParserCtxt() and
xmlParseChunk() instead of xmlCreateIOParserCtxt and xmlParseDocument().
(I don't know whether my first method absolutely requires this - but I'm
assuming that all the other libxml SAX routines want the whole document at
once.)

Method 1:  ost::XMLStream::parse() does a loop until it encounters and
error or the end of the document, and each time through that loop, it does
a read() (as in its virtual member) and sends the read data to
xmlParseChunk().

Method 2:  ost::XMLStream::parse() takes a string containing a portion of
the XML data stream (hence the name, XMLStream, right?) and sends it to
xmlParseChunk().

The reason that this is important to me is that I'm writing a Jabber
client library (as part of a much larger project, but you have to start
with the foundation...), and need to read in and process one level-1 child
of the root element at a time.  I have my own XML stream library working
to do that and send each level-1 child to a callback function, but I've
found that only when I reach the end of a document (which doesn't happen
until the very end of your Jabber connection) do the various callbacks
(aside from beginDocument) get called.

I would write this feature myself, but I'd rather see things done the
CommonC++-prefered way, so that when I upgrade to a future version of the
library I don't have to deal with custom patches.
 -- Ari Johnson






reply via email to

[Prev in Thread] Current Thread [Next in Thread]