我正在尝试让NSXMLParser解析一个如下所示的文件:
<message>
<id>73</id>
<data><(some BLOB data)></data>
</message>
这是我的对象代码:
- (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data
{
if (receivedData == nil) {
receivedData = [[NSMutableData alloc] init];
}
[receivedData appendData:data];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
if (parser) {
[parser release];
parser = nil;
}
parser = [[[NSXMLParser alloc] initWithData:receivedData] retain];
if (parser == nil) {
NSLog(@"Error occured");
}
[parser setDelegate:self];
[parser parse];
}
我很确定变量receiveData不为空。但是NSXMLParser一直在给我这个错误:
Error Domain=NSXMLParserErrorDomain Code=4 "The operation couldn't be completed. (NSXMLParserErrorDomain error 4.)"
根据Apple提供的参考,此错误表明解析器正在解析空文档。 谁知道为什么? receiveData很大,因为它包含音频信息