[Expat-discuss] Abort parsing from inside an handler?
Karl Waclawek
karl at waclawek.net
Tue Oct 28 17:38:25 EST 2003
> Hi,
>
> Let say I'm inside the elementstart handler and I detect something wrong in
> the file format.
> I want to stop the parsing process.
>
> Right now I do the following:
>
> In my userdata structure I have:
> bool bolError
>
> In my elementstart handler, if I detect an error, I set bolError to true.
>
> In my main loop, after the XML_Parse call, I check the bolError flag and I
> stop the parsing if necessary.
>
> It work not so bad but the parsing does not stop immediately when I catch
> the error but when the current buffer sent to XML_Parse in completely
> parsed.
>
> So my question is: is there a way to abort the parsing from inside an
> handler?
Yes, use setjmp/longjmp when using C, or throw an exception
when using a language that has exceptions.
Karl
More information about the Expat-discuss
mailing list