Objective c 如何在iphonesdk中的某个时刻停止libxml解析器中的连接?

Objective c 如何在iphonesdk中的某个时刻停止libxml解析器中的连接?,objective-c,Objective C,我需要在某个时刻停止libxml解析器的连接。有人能建议我怎么做吗 这是我用来建立连接的方法 - (BOOL)parseWithLibXML2Parser { BOOL success = NO; ZohoAppDelegate *appDelegate = (ZohoAppDelegate*) [ [UIApplication sharedApplication] delegate]; NSString* curl; if ([self.lateFeeName length] == 0)

我需要在某个时刻停止libxml解析器的连接。有人能建议我怎么做吗

这是我用来建立连接的方法

 - (BOOL)parseWithLibXML2Parser 
{
BOOL success = NO;
ZohoAppDelegate *appDelegate = (ZohoAppDelegate*) [ [UIApplication sharedApplication] delegate];
NSString* curl;
if ([self.lateFeeName length] == 0) 
{
    curl = @"https://invoice.zoho.com/api/view/settings/latefees?ticket=";
    curl = [curl stringByAppendingString:appDelegate.ticket];
    curl = [curl stringByAppendingString:@"&apikey=bfc9c6dde7c889a19f8deea9d75345cd"];
    curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""];
}

NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:curl]];

NSLog(@"the request parserWithLibXml2Parser %@",theRequest);
NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

self.connection = con;
[con release];
// This creates a context for "push" parsing in which chunks of data that are 
// not "well balanced" can be passed to the context for streaming parsing. 
// The handler structure defined above will be used for all the parsing. The
// second argument, self, will be passed as user data to each of the SAX
// handlers. The last three arguments are left blank to avoid creating a tree
// in memory.
_xmlParserContext = xmlCreatePushParserCtxt(&simpleSAXHandlerStruct, self, NULL, 0, NULL);
if(self.connection != nil) 
{
    do 
    {
        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
    } while (!_done && !self.error);
}
if(self.error) 
{
    [self.delegate parser:self encounteredError:nil];
} else 
{
    success = YES;
}
return success;
}
事实上,在加载数据的过程中,当我点击后退按钮时,我得到了一个异常

// Called when a chunk of data has been downloaded.
- (void)connection:(NSURLConnection *)connection 
didReceiveData:(NSData *)data 
{
// Process the downloaded chunk of data.
xmlParseChunk(_xmlParserContext, (const char *)[data bytes], [data length], 0);//....Getting Exception at this line.
}
任何人的帮助我都将不胜感激

谢谢,,
Monish.

libxml2api中提供的
xmlStopParser
-函数可能正是您想要的

在文档中指定为
void xmlStopParser(xmlparserctptr上下文)

文档可在以下位置获得:

另外,Alex在这方面有一个很好的建议: