I'm going to parse an xml file into my iOS app. Well, I could do it when I just use the url of xml file, but I want to be able to parse the file when it is in Xcode project. so I used the following code:
NSURL *xmlFile = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Prices" ofType:@"xml"]];
NSXMLParser *xmlParser = [[NSXMLParser alloc]initWithContentsOfURL:xmlFile];
but it doesn't parse, I even used the following as well
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Prices.xml"];
NSData *data = [[NSData alloc]initWithContentsOfFile:path];
NSXMLParser *xmlParser = [[NSXMLParser alloc]initWithData:data];
still no parsing, but if I parse it from url it works
NSURL *url = [[NSURL alloc] initWithString:@"http://myurl/Data.xml"];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
I need to parse the file inside the project not using the url, but after searching a lot on similar questions, I'm still not able to do it.