NSXMLParserErrorDomain 111 [英] NSXMLParserErrorDomain 111
问题描述
下面的代码是打印以下消息: Error Domain = NSXMLParserErrorDomain Code = 111无法完成操作。(NSXMLParserErrorDomain错误111。)
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]);
有人有线索吗?正如您在代码中看到的那样,html采用ISO-8859-1编码。
Anybody have a clue? As you can see by the code, the html is with ISO-8859-1 encoding.
更新:我将url提交到html验证器站点: http://validator.w3.org/ 它发现了30多个错误。我认为这与错误有关。但我可以用HPPLE解析html。
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.
推荐答案
似乎没有人偶然发现了正确的答案,所以现在就是这样。
Seems nobody has stumbled on the correct answer yet, so here it is.
在 NSXMLParserError文档,它说:
以下错误代码由NSXMLParser定义。对于此处未列出的错误代码,请参阅< libxml / xmlerror.h>头文件。
The following error codes are defined by NSXMLParser. For error codes not listed here, see the <libxml/xmlerror.h> header file.
未提及数字111在此列表中,我们转到 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/libxml/xmlerror .h
,并找到值:
The number 111 isn't mentioned in this list, so we go to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/libxml/xmlerror.h
, and find the value:
XML_ERR_USER_STOP, /* 111 */
libxml2中的 XML_ERR_USER_STOP
上没有很多文档,但是从阅读变更集,它看起来很快 - 解析器看到意外的EOF时失败。
There isn't a lot of documentation on XML_ERR_USER_STOP
in libxml2, but from reading the changeset, it looks like it's a fast-fail when the parser sees an unexpected EOF.
这篇关于NSXMLParserErrorDomain 111的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!