R – xml parsing problem in iPhone

iphoneparsingxml

I have this xml feed in Chinese, which NSXLParsers is unable to parse. It gives error 31 while parsing.

error 31 occur due to Document encoding is unknown.

I tried UTF-8 and ascii encodings to convert string rendered via

[NSString stringwithContentsOfURL:@"http://news.baidu.com/n?cmd=4&class=finannews&tn=rss"]

to corresponding format.

Can any body shed some light on how to parse XML feeds written in another languages.

Thanx in advance

Best Answer

Try to debugg using

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
    NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
    NSLog(@"error parsing XML: %@", errorString);

    UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [errorAlert show];
}

It will help to find whether the problem is with the xml or the encoding method