Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing an XML file stored in the Documents directory of an iPhone application

NSXMLParser has three types of init.

-> init

-> initWith Data

-> initWithContents of URL


=> But my xml file is stored at Application's Document directory, so how to parse a file which is stored at "Doc Dir"

Thanks in advance.

like image 303
Sagar Kothari Avatar asked Aug 24 '09 19:08

Sagar Kothari


1 Answers

nsdata can be initialize with the contents of a file. Use the initWithContentsOfFile instance method with NSDAta and supply that to nsxmlparser's initWithData method:

NSString * filePath = [[NSBundle mainBundle] pathForResource:@"someFile"
                                                      ofType:@"xml"];
NSData * fileData = [NSData dataWithContentsOfFile:filePath];
NSXMLParser * parser = [NSXMLParser initWithData:fileData];
like image 73
ennuikiller Avatar answered Oct 06 '22 00:10

ennuikiller