本文介绍了使用NSXMLParser从HTTPS URL解析XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我尝试直接从HTTPS网址解析XML,如下所示:I'm trying to parse XML directly from an HTTPS URL, as follows:NSString *const URL = @"https://some/HTTPS/url";NSURL* url = [NSURL URLWithString:URL];NSXMLParser* parser = [[NSXMLParser alloc] initWithContentsOfURL:url];[parser setDelegate:self];[parser parse];我有一个解析器的委托方法:I have the following delegate method for the parser:- (void) parser:(NSXMLParser *)parserdidStartElement:(NSString *)elementNamenamespaceURI:(NSString *)namespaceURIqualifiedName:(NSString *)qualifiedNameattributes:(NSDictionary *)attributeDict{ NSLog(@"Started parsing %@", elementName);}这似乎适用于HTTP网址,但没有显示任何结果网址。This seems to work fine for HTTP URL's, but shows no result for an HTTPS URL.如何解决此问题?推荐答案 initWithContentsOfURL:...方法都不允许您回答来自https服务器的身份验证消息。因此,请查看 NSURLConnection 和 NSURLD下载。要详细了解如何使用URL与服务器进行通信,请阅读网址加载系统简介。To learn more about using URL's for communicating with servers read Introduction to the URL Loading System.至于使用XML解析器解析HTML,它只能可靠地使用XHTML。所以,如果你正在创建和解析自己的XHTML文件,应该在大多数情况下工作。但是如果你从互联网加载任何HTML文件,那么XML解析器通常不能解析该文件。您可能需要查看 WebKit 。 p>As far as parsing HTML with an XML parser, it will only reliably work with XHTML. So if you are creating and parsing your own XHTML files that should work in most cases. But if you are loading any HTML file from the internet then the XML parser will often not be able to parse the file. You may want to look at WebKit for that. 这篇关于使用NSXMLParser从HTTPS URL解析XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-14 19:55