Altova Mailing List Archives
>microsoft.public.xml Archive Home
>Thread Prev - Partial SAX parsing
Re: Partial SAX parsing
Date: 8/21/2004 11:56:00 PM
Chris Warr <cwarr@--no-spam--.labyrinth.net.au> wrote: > Hi, I'm working on an existing app. that parses an xml doc with SAX and does > some work in start_element and end_element handlers. My problem is I need > to speed things up a bit, only 1/4 of the xml document is relevant, I'd > rather not have SAX go down some paths, ie. In the following: > > <doc> > <interesting-stuff> > <things>...</things> > </interesting-stuff> > <boring-stuff> > <blah>...</blah> > </boring-stuff> > </doc> > > I want sax to process the elements below interesting-stuff but not below > boring-stuff. Is this level of control possible? Or can you only process > every element? In start callback, if element is <boriing-stuff>, then zero all handlers except for end handler. In end callback, if element is </boriing-stuff>, re-register your normal handlers. Or, use global flag, and test for it in every handler you have.