xmlparser parse returns no always, how to fix?
NSURL *url = [[NSURL alloc] initWithString:@"..."];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
//Initialize the delegate.
XMLParser *parser = [[XMLParser alloc] initXMLParser];
//Set delegate
[xmlParser setDelegate:parser];
//Start parsing the XML file.
BOOL success = [xmlParser parse];
if(success)
NSLog(@"No Errors");
else
NSLog(@"Error Error Error!!!");
[x开发者_开发技巧mlparser parse]
returns no . Why is that happening?
output: Error Error Error!!!
If you implement the parseErrorOccurred:
method in your delegate XMLParser
class, it will give you the exact reason for the errors.
Something like:
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSLog(@"NSXMLParser ERROR: %@ - %@", , [parseError localizedDescription], [parseError localizedFailureReason]);
}
精彩评论