Android Question How do you stop XmlSax processing on Exception.

cimperia

Active Member
Licensed User
Longtime User
Here's a general question about XmlSax.

How do you recover from error, or more exactly how do you stop processing when an exception is raised?

More specifically, if an exception is raised in _StartElement or _EndElement procedures, you can try/catch the exceptions, but it does not stop the processing all together and the two subs will be called until the end of the stream.

It's obviously no good to wrap the call to parser.Parse in a try/catch block as the exception won't be relayed.

So, to reiterate, how do you stop the processing when an exception is raised?

Thank you.
 
Last edited:

cimperia

Active Member
Licensed User
Longtime User
Well, yes it's true that letting the exception uncaught will stop the parsing, but then there's no way to recover cleanly, is there? I had a look at Xml2Map and I wanted to avoid using it as my SmlSax routines are working just fine, until the data started to get rather dirty that is.
 
Upvote 0

cimperia

Active Member
Licensed User
Longtime User
No that won't work. I tried that and the exception is not relayed back, so to speak. More precisely, if the exception is not handled in the _Start _End routine, then only Application_Error will be triggered.
 
Upvote 0

cimperia

Active Member
Licensed User
Longtime User
It's what I did. I used a global fail flag, but it's not very nice though. It stops the elements being processed but the _Start and _End Subs are still called for every element until the end of the stream.

Anyway, thank you for your input. I reckon that the XmlSax implementation requires some more work to make it more user friendly. I'll see how much effort there is in rewriting my routines with Xml2Map .
 
Last edited:
Upvote 0
Top