开发者

How to read a local xml file

开发者 https://www.devze.com 2023-01-04 15:40 出处:网络
I want to create a NSURL object out of a NSString, where I use -fileURLWithPath:(NSString ) I put my xml file as my source file, and name it event.xml.

I want to create a NSURL object out of a NSString, where I use -fileURLWithPath:(NSString ) I put my xml file as my source file, and name it event.xml. But NSString URL = @"event.xml"; NSURL a = [NSURL fileURLWithPath:URL];

but then my xmlparser return a connection failed error.

so what's the correct way to specify the path of a xml in the source file?

sorry about the formatti开发者_JAVA技巧ng but I'm really in a rush


That depends on the directory your XML file is in. If we are talking about a file in your app bundle, it is:

NSString *path = [[NSBundle mainBundle] pathForResource:@"event" ofType:@"xml"];
0

精彩评论

暂无评论...
验证码 换一张
取 消