3

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

RawMean
  • 8,374
  • 6
  • 55
  • 82
luyi326
  • 71
  • 1
  • 5
  • will this help ? http://stackoverflow.com/questions/7304850/parser-error-error-domain-nsxmlparsererrordomain-code-4-the-operation-couldnt – Roshit May 31 '12 at 09:39
  • can you log the receivedData? can you show also how your XML looks like (~10 first lines) – Hosni May 31 '12 at 09:43
  • Well the receivedData generally looks like a ten-page long version of this: 1f8b0800 00000000 0003ecdd 49ae2dd9 969de7b2 d88a5552 55966e33 0309f6c5 52418054 22fb0fcd – luyi326 May 31 '12 at 16:36
  • @Roshit thanks for that but I think it's kind of different – luyi326 May 31 '12 at 16:37
  • @Hosni the first few lines in XML: 73 <63616666 00010000 64657363 00000000 00000020 40e58880 00000000 696d6134 00000000 00000044 00000040 00000002 00000000 6b756b69 00000000 00000000 66726565 00000000 00000fa4 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 – luyi326 May 31 '12 at 16:40
  • this is the ending: 982b840b ff92a824 9a08f986 80808080 80000808 08888080 90000000 00000000 00000000 0000ff92 a8249a08 f9868080 80808000 08080888 80809000 00000000 00000000 00000000> the angle brackets within the block is using HTML entities – luyi326 May 31 '12 at 16:42

0 Answers0