[Expat-discuss] how to use XML_StopParser from within a handler?

kwaclaw@teksavvy.com kwaclaw at teksavvy.com
Thu Jul 7 23:16:06 CEST 2005


> Hi,
> 
> I've looked in reference.html and the mailing list but can't find an 
> answer to this basic question. My application traverses an XML document 
> until it finds what it's looking for, at which point it's done. I.e. 
> there's no point continuing to parse once that's been found, and the 
> section it's looking for can occur anywhere in the document. I could 
> just set a flag and abandon parsing the next time XML_Parse() returns 
> but according to the API it seems like XML_StopParser (with resumable=0) 
> is the "right" thing to do, presumably followed by XML_ParserFree once 
> XML_Parse returns.
> 
> The doc for XML_StopParser says it should be invoked from a callback 
> handler. But its signature indicates it takes a pointer to the parser 
> object and that object is not presented to the handler. So how am I to 
> use XML_StopParser from within a callback? Must I make the parser object 
> static?

No, that is what the userData pointer is for.
It points to memory managed by your app,
where you can store the parser reference.

Karl


More information about the Expat-discuss mailing list