I'm trying to get NSXMLParser to parse an file looks like this:
<message>
<id>73</id>
<data><(some BLOB data)></data>
</message>
and this is my obj-c code:
- (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];
}
I'm pretty sure that the variable receiveData is not empty. But NSXMLParser is keep giving me this error:
Error Domain=NSXMLParserErrorDomain Code=4 "The operation couldn't be completed. (NSXMLParserErrorDomain error 4.)"
According to reference provided by Apple this error indicate that the parser is parsing an empty document. Anyone knows why? The receiveData is huge since it contains audio information