NSXMLParserErrorDomain的意思是什么? [英] What is the meaning of NSXMLParserErrorDomain error 5.?

查看:140
本文介绍了NSXMLParserErrorDomain的意思是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我回来了这个任务。我有我的XML正确地从我的网络服务器下载一个URL指向服务器的文件,但是,当我检测到网络是不可达的,我只是指向我的应用程序的本地XML的URL,我得到以下错误(NB的文件在服务器上的直接副本)。

Ok, I am back on this task. I have my XML properly download from my webserver with a URL pointing to the server's file, however, when I detect the network is 'unreachable' I simply point the URL to my application's local XML and I get the following error (N.B. the file is a direct copy of the one on the server).

我找不到详细说明,但我认为这是指该网址指向无法访问的位置。我将此资源存储在错误的位置吗?我想我希望它在HomeDirectory / Library中

I cannot find detail description, but I think it is saying that the URL is pointing to an inaccessible location. Am I storing this resource in the wrong location? I think I want it in the HomeDirectory / Library??

调试输出


loadMyXml: /var/mobile/Applications/950569B0-6113-48FC-A184-4F1B67A0510F/MyApp.app/SampleHtml.xml
2009-10-14 22:08:17.257 MyApp[288:207] Wah! It didn't work. Error Domain=NSXMLParserErrorDomain Code=5 "Operation could not be completed.   (NSXMLParserErrorDomain error 5.)" 
2009-10-14 22:08:17.270 MyApp[288:207] Operation could not be completed. (NSXMLParserErrorDomain error 5.)


推荐答案

根据Dave DeLong,

According to Dave DeLong,


这意味着它解析你的文件有问题。

That means it's having issues parsing your file.

可以是XML中的XSLT引用 - 因为它指向Web服务器。我将审查并回答这个问题,并提供一个改进的答案。

I think it may be the XSLT reference in the XML - as it points to the webserver. I will review and get back to this question with an improved answer.

这是文件的路径。我的代码甚至没有接近正确的位置 - 我缺少一个后面的字母's'。错误代码定义意味着文件过早结束,这导致我截断我的文件没有任何成功。然后我回到基础和迭代在文件系统上寻找我的文件。

It was the path of the file. My code wasn't even close to the right location -- and I was missing a trailing letter 's'. The error code definition implies a "premature end of file", which caused me to truncate my file without any success. I then went back to basics and iterated on the file system to look for my file.

我调试通过使用NSFileManager迭代到我的文件,然后验证它是可以使用 contentsAtPath 方法加载。我能够转储它与NSLog()。一旦我确信文件格式正确,并以原始形式加载,我确信我的NSURL是用相同的语法和方法构造的。然后正确加载。现在我可以加载网络文件全功能内容或本地示例内容。

I debugged by using the NSFileManager to iterate to my file and then verified that it was loadable with the contentsAtPath method. I was able to dump it with NSLog(). Once I was convinced that the file was well-formed and loaded in raw form, I made certain that my NSURL was constructed with the same syntax and methods. Then it loaded correctly. Now I can load either a network file "full-featured" content or a local "sample" content.

NSDirectoryEnumerator *dirEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: NSHomeDirectory()];
NSString *something;
NSString *f;

while( something = [dirEnumerator nextObject] ) {
    f = [[[NSString alloc] initWithFormat: @"%@/%@", NSHomeDirectory(), something] autorelease];
    if( [f hasSuffix :@"two_cookies.xml"] ){
    NSData *nsData = (NSData*) [[NSFileManager defaultManager] contentsAtPath: f];
        NSLog(@"%@", nsData );
    }
}

输出

2009-10-22 00:47:40.147 MyApp[13843:20b] <?xml version="1.0" encoding="iso-8859-1"?>

我希望我的明确这里是有帮助的人,因为他们调试其数据处理。

P.S. I hope my being explicit here is helpful to others as they debug their data processing.

这篇关于NSXMLParserErrorDomain的意思是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆