NSXMLParserErrorDomain 111

Viewed 10229

The code below is printing the following message: Error Domain=NSXMLParserErrorDomain Code=111 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 111.)

mainUrl = [NSURL URLWithString:@"http://www.carris.pt/pt/carreiras"];
NSString *urlContents = [NSString stringWithContentsOfURL:mainUrl encoding:NSISOLatin1StringEncoding error:nil];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:[urlContents dataUsingEncoding:NSISOLatin1StringEncoding]];
[xmlParser parse];
NSLog(@"%@", [xmlParser parserError]);

Anybody have a clue? As you can see by the code, the html is with ISO-8859-1 encoding.

Update: I submitted the url to the html validator site: http://validator.w3.org/ and it found over 30 errors. I think that has something to do with the error. But I can parse the html just fine with HPPLE.

5 Answers

I have recently ran into same error and found that the problem was invalid XML tags. There is no error on front-end code but the problem was at the backend site. To illustrate, my received XML data like this:

    <TABLE>
      <item>
           <0>memo</0>
           <1>179</1>
      </item>
    </TABLE>

And got error (NSXMLParseErrorDomain=111) when tried to parse the element that name tag is 0 or 1. Then I have changed the XML like this at the backend;

    <TABLE>
     <item>
        <name>memo</name>
        <weight>179</weight>
     </item>
    </TABLE>

Then parsing worked perfectly as the previous XML has invalid tag name.

Related