解析错误=错误域= NSXMLParserErrorDomain代码= 5“无法完成操作。(NSXMLParserErrorDomain错误5.)”

时间:2012-08-05 13:20:48

标签: objective-c nsxmlparser

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSLog(@"3 DONE. Received Bytes: %d", [getMagaListsWebData length]);
    NSString *recievedXML = [[NSString alloc]initWithData:getMagaListsWebData encoding:NSUTF8StringEncoding];

    [recievedXML release];
    //重新加載xmlParser
    if(getMagaListsXmlParser){
        [getMagaListsXmlParser release];
        getMagaListsXmlParser = nil;
    }
    getMagaListsXmlParser = [[NSXMLParser alloc]initWithData:getMagaListsWebData];
    [getMagaListsXmlParser setDelegate: self];
    [getMagaListsXmlParser setShouldResolveExternalEntities: YES];
    [getMagaListsXmlParser parse];
    if (![getMagaListsXmlParser parse]) {
        NSLog(@"parse error = %@", [getMagaListsXmlParser parserError]);
        //theConnection = [[NSURLConnection alloc] initWithRequest:getMagaListsRequest delegate:self startImmediately:YES];
    }
}

我收到了错误消息:

parse error = Error Domain=NSXMLParserErrorDomain
  Code=5 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 5.)"

1 个答案:

答案 0 :(得分:2)

一个非常有用的技巧是突出显示有问题的错误/域

NSXMLParser.h, NSXMLParserPrematureDocumentEndError = 5,

看起来您的入站文档存在问题,可能是某处的不平衡块。