Trouble getting ISO-8859-1 encoded feed to parse and display
Trouble getting ISO-8859-1 encoded feed to parse and display
- Subject: Trouble getting ISO-8859-1 encoded feed to parse and display
- From: Diederik Meijer | Ten Horses <email@hidden>
- Date: Sun, 23 Nov 2014 22:06:09 +0100
Hi list,
I am having trouble getting useful data from this url on some, but not all, iOS devices: https://www.taxpublications.deloitte.co.uk/tis/dtp.nsf/pub1.xml
The feed has this opening tag: <?xml version="1.0" encoding="ISO-8859-1" ?>
When I just pull in the feed’s contents using a NSURLConnection, it will show up on some, but not all, devices.
When I try to log the response data, by creating a string that I init with the downloaded data and NSUTF8StringEncoding, the log will show a null string. So putting the downloaded data into a string using UTF8 doesn’t work.
NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSUTF8StringEncoding];
Still, in that case, some devices will show the parsed feed, some won’t.
I tried converting the data into NSISOLatin1 and then putting it back into NSData using UTF8, as below, but that doesn’t help.
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSISOLatin1StringEncoding];
[self setDataContainer:[[dataString dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]];
self.xmlItems = [NSMutableArray array];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.dataContainer];
[parser setDelegate:self];
[parser parse];
}
I validated the feed’s XML and got no errors..
Anybody out there with experience in solving this?
Many thanks!
Diederik
_______________________________________________
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