對於我正在編寫的XML應用程序,我正在使用以下tutorial,但我無法弄清楚如何將NSURL更改爲XML文件在iPhone上的位置。在iPhone上解析XML
//XMLAppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSURL *url = [[NSURL alloc] initWithString:@"sites.google.com/site/iphonesdktutorials/xml/...";
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
//Initialize the delegate.
XMLParser *parser = [[XMLParser alloc] initXMLParser];
//Set delegate [xmlParser setDelegate:parser];
BOOL success = [xmlParser parse];
if(success)
NSLog(@"No Errors");
else
NSLog(@"Error Error Error!!!");
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
可能是'''NSURL * url = [[NSURL alloc] initWithString:@「http://sites.google.com /site/iphonesdktutorials/xml/Books.xml「];'''? – 2012-08-08 12:48:49
請發佈您用來加載數據文件的代碼。 – Caleb 2012-08-08 12:48:59
我不希望它從Web服務中讀取。我需要iPhone上的XML文件。應用必須從那裏讀取 – Scubadivingfool 2012-08-08 13:32:44