Re: [xml] stopping parsing



On Thu, 30 Oct 2003, Graham Bennett wrote:

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.

I do that with a somewhat-inelegant hack that uses chunked parsing,
and simply stops stops feeding chunks to the parser when it's found
what I'm looking for.  That means only a small amount of extra
parsing will happen.

        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.

Yep, that's also useful.  Though the effect is fairly negligible,
unless your callbacks do some heavyweight processing.

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.

That's something I hadn't seen.  Is it a newish call?  Is it available
in the htmlParser?

-- 
Nick Kew





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