Re: NSXMLParserDelegateAbortedParseError
Re: NSXMLParserDelegateAbortedParseError
- Subject: Re: NSXMLParserDelegateAbortedParseError
- From: Kevin Bracey <email@hidden>
- Date: Wed, 09 Mar 2011 10:33:49 +1300
Hi Josh,
So you are not getting a parsing error, you're using the wrong mechanism. By calling abort you are setting the parsers error code, that code has nothing to do with the fact you are parsing some XML with "error" in it. I think you are confusing a Parsing Error and a valid XML stream with an Error Message, these are not the same thing. Your parser should handle both types of streams without posting a "parser error". Then you handle the results, If it was full data, do stuff, if it was "Error" data then do error stuff.
cheers
Kevin
On 9/03/2011, at 10:13 AM, Josh Caswell wrote:
> Hi Kevin,
>
> Thanks for your reply.
>
> Sorry, maybe my explanation is not clear enough (I may have left out
> too many details). It's not a network error that I am talking about,
> but, as you say, an API error for which the server returns valid XML.
>
> The specifics:
> I'm requesting weather data for a location by latitude and longitude.
> If I give the server a request that has, for example, a bad latitude,
> it will return valid XML, which parses fine, with an error element and
> a message describing the problem with the request:
>
> <Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="http://na.unep.net/swera_ims/WS/SWERA.xsd"><Error>110</Error><ErrorMessage>Latitude
> point must be between -90 and 90</ErrorMessage></Data>
>
> If my parser comes upon an Error element, the delegate tells it to get
> the ErrorMessage contents and then aborts the parsing. Then the
> message ("Latitude point must be between...") is used for an alert
> sheet as I described.
>
> I'm just wondering why, after my delegate aborts the parse, the parser
> changes the error code.
>
> -- Josh Caswell
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden