NSXMLParserErrorDomain 111

pedroremedios picture pedroremedios · Dec 8, 2013 · Viewed 9.3k times · Source

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.

Answer

Dan Waylonis picture Dan Waylonis · Jul 24, 2014

I also had the "111" (undocumented?) error code when parsing. It turns out that the XML Parser expects the XML to be well formed (e.g., one root node that contains all the others).