[Expat-discuss] Terminating the parser

Karl Waclawek karl@waclawek.net
Thu Nov 21 14:02:08 2002


> Hi,
> Suppose I detect an error in one of the handlers (e.g., 
> in the StartElementHandler).
> How do I tell Expat to stop parsing the document?
> The handlers are all defined as void, so I can't return an error code to Expat.
> Is there some error flag that I can turn on and the parser will check?

Depends on the language you are calling Expat from.
In C++ or Delphi I would raise/throw an exception.

In C, one can use setjmp/longjmp. Check out the mailing list
archives - this has been discussed in the past couple of months.

Currently there is no such return value for handlers.
A workaround would be to clear all handlers when the error
is detected, set a flag, and stop processing when the
next call to XML_GetBuffer/XMLParseBuffer comes up.

Karl



More information about the Expat-discuss mailing list