in reply to Catch XML error

The post above will give you an answer to your problem. Now I'm trying to persuade you from solving the problem in the way you want.

XML documents have a very strictly defined format. All conforming parsers will throw an exception for the input you describe, because the input is not XML and the "correct" thing to do is to reject the whole input file.

This makes sense when you use XML to transfer data between systems - you generally don't know much about the sending system, and if the input doesn't conform to the specs, the right attitude to take is that the other system has just thrown a bug or the stream has been mangled during transfer.

Again; your input is not XML. Trying to subvert the XML specs is fine by me, but you should not expect any standard XML tools to help you do it, and other developers/spec-writers will probably not understand all the subtleties involved. The full XML spec really is not as easy as you'd think from reading a couple of XML files. If you're diverting from it, you'd better make really sure you know what you're doing.

Replies are listed 'Best First'.
Re^2: Catch XML error
by ecuguru (Monk) on Jul 17, 2007 at 19:01 UTC
    fair. It's a headless app sitting on a remote box. I need to know if it's getting an error (dies to a function that shoots me a note). Not subverting, just doing better error handling to know if something bad this way came-ith.