tags:

views:

138

answers:

2

Hi All,

I am using NSXMLParser to parse the html file on the server side.(using iphone sdk 3.0) and my parser stop parsing after it encounter any error and call the delegate message

  • (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError

My Ques:How can I parse the file after it encounter the error.Is there any way to do so.

Thanks

+1  A: 

You can't. Parsing is stopped when the error is encountered. It would be hard to know what the rest of an erroneous XML document meant, anyway, as the meaning of anything at one location in the document depends on everything that came before it (in this case, including an error).

Graham Lee
A: 

You're looking for a different kind of parser. An "at-all-costs" parser would be able to do what you want. If you are getting XML from lots of different sources this is ideal.

If you have a few sources you can workaround their problems. For instance, if the only issue you get is that they told you it was UTF-8 when it turns out it is ISO-8859-1 you could run through it once, find out it fails due to a character issue, convert the XML from ISO-8859-1 to UTF-8 and try again. Since you know where the error was you can try to make some sort of fix. It's quite expensive to go this route though.

Epsilon Prime