On Tue, Apr 29, 2008 at 7:36 PM, Jens Alfke <[EMAIL PROTECTED]> wrote:
> > On 29 Apr '08, at 6:27 AM, Lorenzo Thurman wrote: > > I tried loading the XML into an NSString using > > initWithContentsOfURL:encoding:error using Latin1 encoding. Under Leopard, > > the XML is read in just fine. I can output the resulting string in the > > debugger and it looks good and is parsed just fine. Under Tiger, the string > > is just a bunch of unicode escape sequences and results in another empty > > document error after running through NSXMLParser. I'm running on PPC with > > 10.4.11, if that matters at all. > > > > Sounds like the document is not actually in ISO-Latin-1. It may be that > Leopard is detecting that you gave the wrong encoding and using the correct > one specified by the server instead, whereas Tiger just uses what you gave > it. > > It's pretty rare that you need to force an encoding when downloading text > from a URL. Try using this NSString method, which will try to determine the > encoding automatically (either from the HTTP headers or by sniffing the > bytes): > > + (id)stringWithContentsOfURL:(NSURL *)url usedEncoding:(NSStringEncoding > *)enc error:(NSError **)error; > > —Jens I finally found a way to get it working. I did it this way: NSXMLDocument* theDoc = [[[NSXMLDocument alloc] initWithContentsOfURL:[NSURL URLWithString:urlString] options:NSXMLDocumentTidyXML error:&err] autorelease]; NSData* xmlData = [theDoc XMLData]; NSXMLParser* parser = [[[NSXMLParser alloc] initWithData:xmlData] autorelease]; [parser setDelegate:self]; [parser parse]; I tried an earlier suggestion of saving the data to a file and then running tidy on it. tidy reported about 300 errors. That gave me the idea to try using NSXMLDocument, since it has the tidyXML option. This works perfectly under both 10.5 and 10.5. I'll try what you suggest above, just to see what happens, but I'm happy again. Thanks for the help. -- "My break-dancing days are over, but there's always the funky chicken" --The Full Monty _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]