• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Reading in XML with iso-8859-1 encoding?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading in XML with iso-8859-1 encoding?


  • Subject: Reading in XML with iso-8859-1 encoding?
  • From: Amy Gibbs <email@hidden>
  • Date: Sat, 6 Dec 2008 10:35:12 +0000

I've got a web based xml file in iso-8859-1 encoding that I'm trying to read into an NSXMLDocument.

I've got the following code, but I can't seem to make it work? (I've tried all manner of combinations)


//create the url
NSString *urlString = [NSString stringWithFormat:
@"http://www.willowtreecrafts.co.uk/ag/ sesbuddyimport.php"];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:30];
//fetch the xml response
NSData *urlData;
NSURLResponse *response;
NSError *error;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];


if (!urlData){
NSAlert *alert=[NSAlert alertWithError:error];
[alert runModal];
return;

}
//parse the xml response
[doc release];
[doc setCharacterEncoding:@"iso-8859-1"];
//NSString *xmlstring = [NSString stringWithContentsOfURL:url usedEncoding:@"iso-8859-1" error:&error];
doc=[[NSXMLDocument alloc]initWithData:urlData options:0 error:&error ];

//doc=[[NSXMLDocument alloc]initWithContentsOfURL:url options:0 error:&error];
//doc=[[NSXMLDocument alloc]initWithXMLString:xmlstring options:0 error:&error];



I get an error telling me that the input is not in UTF-8 encoding. I know the input isn't UTF-8, but how can I get it to accept the iso-8859-1 file?


Thanks


_______________________________________________

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


  • Follow-Ups:
    • Re: Reading in XML with iso-8859-1 encoding?
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Core Data request predicates and to-many relationships
  • Next by Date: Re: Fix Populated NSMenu Of Files, Folders And Their Respected Images
  • Previous by thread: Re: [RESOLVED] Core Data request predicates and to-many relationships
  • Next by thread: Re: Reading in XML with iso-8859-1 encoding?
  • Index(es):
    • Date
    • Thread