Re: [xml] stopping parsing



On Thu, Oct 30, 2003 at 10:50:19PM +0000, Graham Bennett wrote:
Hi all,

What's the best way of stopping the parser from the SAX interface?

My situation is this:  I'm doing 'partial' parsing of a document which
involves stopping when a certain element is reached and not doing any
more processing.  My initial solution was to NULL out all of my
callbacks in the SAX handler so that the parser runs through to the end
without my code receiving any more events.  This seems to work, but it
would be nice to be able to stop the parser in its tracks rather than
letting it finish the document.

I looked at xmlStopParser, but I will tend to call this when I hit a
start element, and the parser will give me errors back saying that it
hit the end of the data before seeing the end element.

  Hum, the problem is that the parser drives the data consumption.
And unless adding check for the condition set by xmlStopParser() in
a lot of places it's hard to make an instantaneous stop.
  Still bugzilla it, it should be relatively simple to find at least
a few crucial spots where this condition could be tested to exit faster.
Resetting all the callbacks is a bit extreme that can probably be avoided
(especially now that parsing contexts can be reused).

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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