0
votes

I've got an interesting problem. I have an iPad App which has to parse some XML-Data from the Web and it all works fine in 5.0 Simulator and Device but on iOS 4.3 Simulator (actually i don't have any 4.3 Device available) it won't parse and the [NSXMLParser parse] method retuns NO I already tried downloading the string first then converting it to NSData, aswell as Dowloading the NSData directly and initialize the parser with the downloaded NSData.

Here's my Code

-(void)parseWithURLString:(NSString *)urlString{
    NSURL *url = [NSURL URLWithString:urlString];
    if (url != nil) {
        self.parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
        [[self parser] setDelegate:self];
        if([[self parser] parse]){
            NSLog(@"WOOHOO!");
            [TestFlight passCheckpoint:@"XML has been parsed"];
        }
}

The urlString has been checked and is correct.

1

1 Answers

2
votes

Log the parseError property of your NSXMLParser. That should lead you to know what exactly is your problem.

-(void)parseWithURLString:(NSString *)urlString{
    NSURL *url = [NSURL URLWithString:urlString];
    if (url != nil) {
        self.parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
        [[self parser] setDelegate:self];
        if([[self parser] parse]){
            NSLog(@"Parser completed.");
        }
        else {
            NSLog(@"Parser failed. Error: %@",[self.parser parseError]);
        }
}

Alternatively, you can implement the following protocol and log the error that occurs during parsing:

- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError