【问题标题】:Xml Parsing from URL and saving in to documents directory in IOS [duplicate]Xml从URL解析并保存到IOS中的文档目录[重复]
【发布时间】:2013-03-04 00:23:48
【问题描述】:

大家好,任何人都可以向我推荐任何有关“如何从 URL 下载 XML,将其作为 XML 文件存储在文档文件夹中”的教程 谢谢。

【问题讨论】:

  • 使用 TBXML 库可以直接从 url 下载 XML。

标签: iphone ios objective-c cocoa-touch


【解决方案1】:

下面的代码会对你有所帮助。

NSString *URLString = @"http://www.Sample.com/Sample.xml";
NSURL *URL = [NSURL URLWithString:
          [URLString stringByAddingPercentEscapesUsingEncoding:
           NSASCIIStringEncoding]];


NSData *xmldata = [NSData dataWithContentsOfURL:URL];

NSString *documentsDir =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *path = [documentsDir stringByAppendingPathComponent:@"savedxml.xml"];
[xmldata writeToFile:storePath atomically:TRUE];

希望对你有帮助!!!

【讨论】:

    猜你喜欢
    • 2015-02-04
    • 1970-01-01
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 2015-07-19
    • 1970-01-01
    • 2021-05-23
    • 2015-12-05
    相关资源
    最近更新 更多