我没有从URL加载XML,而是想从文档目录加载它(我在有Internet连接的时候保存了它)
NSString* filename=@"magzine.xml";
NSData *data=[NSData dataWithContentsOfURL:[[NSURL alloc] initWithString:[URLlink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
NSString *applicationDocumentsDir =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:filename];
[data writeToFile:storePath atomically:YES];
NSLog(@"URL: %@",url);
xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
//xmlParser = [[NSXMLParser alloc] initWithContentsOfFile:filename];
[xmlParser setDelegate:self];
[xmlParser parse];
现在我从url获取xml,即来自initwithcontentsofurl,现在我想在没有互联网连接的情况下从文件目录中获取保存的文件。请帮助我,如何加载xml? 感谢提前