在我的应用程序中,我必须解析从Internet下载的XML文件。如何在iphone上下载xml并保存在文档中?然后如何开始解析文档中保存的xml?是吗?
最佳答案
你的意思是这样的
NSString *URLString = @"http://www.example.com/XML/note.xml";
NSURL *URL = [NSURL URLWithString:
[URLString stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding]];
NSData *dataXML = [NSData dataWithContentsOfURL:URL];
NSString *applicationDocumentsDir =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:@"sample.xml"];
[dataXML writeToFile:storePath atomically:TRUE];
NSData *contenuto = [NSData dataWithContentsOfFile:storePath];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:contenuto]
关于iphone - 如何在文档中下载并保存xml,然后如何从文档中解析xml文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3165409/