+1  A: 

the encoding of your file is probably not UTF8.

If you don't know the encoding of your file, you could try this method:

- (id)initWithContentsOfURL:(NSURL *)url usedEncoding:(NSStringEncoding *)enc error:(NSError **)error

you have to pass a pointer to a NSStringEncoding, like you did with error.:

NSURL *url = [[NSURL alloc] initWithString:@"http://my_url.com/my_file.xml"];
NSError *error = nil;
NSStringEncoding encoding;
//NSString *my_string = [[NSString alloc] initWithContentsOfURL:url
//                                                     encoding:NSUTF8StringEncoding
//                                                        error:&error];
NSString *my_string = [[NSString alloc] initWithContentsOfURL:url
                                                 usedEncoding:&encoding 
                                                        error:&error];

after this your encoding is present in the encoding variable. If you are not interested in the used encoding, I guess you could pass NULL as pointer as well.

fluchtpunkt
I tried to change UTF8 to ISOLatin1 (ISOLatin2 works as fine as UTF8). It partially worked : I still have issues with î, ', ô, ...
Nonepse
And How do you use initWithContentsOfURL:usedEncoding:error: ? What is the second parameter ?
Nonepse
@Nonepse I made an edit. HTH
fluchtpunkt
Saw that, thanks, but it's still not working (my_string is null). Anyway, I manually replaced the few characters which were not encoded.
Nonepse
of course if your file is not encoded correctly in any encoding supported by the iphone it can't be decoded properly.
fluchtpunkt
yeah, know that, but I am not allowed to modify my_file.xml :( thanks anyway ;)
Nonepse
A: 

Why not use a request and connection to get the info back in an NSData object? Something like this:

NSURL *url = [[NSURL alloc] initWithString:@"http://my_url.com/my_file.xml"];

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:@"GET"];

NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];

    [conn start];

if(conn){
    // Data Received
    responseData = [[NSMutableData alloc] init];
}

and then in your connection:didRecieveData delegate method, put something like this

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

[self.responseData appendData:data];
}

and then once the connection is finished loading convert the data to a string:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
     NSString *string = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];
}

Not the most straightforward method, but that should get you your XML string. Also if you need to parse the XML once you get it back, you can directly pass the responseData to an NSXMLParser without any conversion. :)

Geoff Baum