XML SAX parser - how to handle parser errors


we are working with Nat for Unix. Our admin recently activated the XML SAX parser option for us, now I’m trying out the PARSE XML statement.
In my test program, I read XML from a work file and then apply the PARSE XML statement. This works as long the XML is ok, but if I read a file with incorrect XML, this results in a Natural error such as 8311 or 8312. Even if I reset the *ERROR-NR an ‘On Error’ block, I cannot reach the code that comes after the PARSE XML statement.
I would like to be able to transform such error situations in a ‘User Error’ situation where I can react appropriately, e.g. do some logging or sending an email from within the routine ‘Attention - you sent us an invalid XML’ or something like that, rather than just abort the current process.#

It would be good to make sure to have at least well-formed XML beforehand, but I thought that’s what the parser is actually there fore?

What would be the best way to handle such errors:

  • placing the PARSE XML in a subprogram with its own ‘ON ERROR’ routine ?
  • Any other alternatives?
    Thanks very much in advance for your comments.

Place the PARSE XML statement in a separate subprogram is indeed the best (and the only in my opinion) solution.