xCode - reload xml from server ( xml parsing second time )

ptnas

New Member
I'm developing a project (Xcode 4.3.2) with reading xml. In this project: first, i have downloaded the xml file from server to local. and I'm trying to read the data, first time its working fine. When i click on the "reload" button, i want to download the server xml again, but when i try the below code, i got NSLog "Error Error Error!!!". Could you please help me.\[code\]-(IBAction)reloadData:(id) sender{ //reloading the data, onButton click [self loadDatafromServer];}-(void)loadXML{ NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *fullName = [NSString stringWithFormat:mad:"xmlfile.xml"]; NSString *fullFilePath = [NSString stringWithFormat:mad:"%@/%@",docDir,fullName]; NSData *myData = http://stackoverflow.com/questions/10206578/[NSData dataWithContentsOfFile:fullFilePath]; NSXMLParser *xmlParser = [[[NSXMLParser alloc] initWithData:myData] autorelease]; [xmlParser setDelegate:self]; //Start parsing the XML file. BOOL success = [xmlParser parse]; if(success) NSLog(@"No Errors"); else NSLog(@"Error Error Error!!!");}-(void) connectionDidFinishLoading:(NSURLConnection *)connection{ //saving data in the local NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *fullName = [NSString stringWithFormat:mad:"xmlfile.xml"]; NSString *fullFilePath = [NSString stringWithFormat:mad:"%@/%@",docDir,fullName]; [receivedData writeToFile:fullFilePath atomically:YES]; [self loadXML];}-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ if (receivedData) [receivedData appendData:data]; else receivedData = http://stackoverflow.com/questions/10206578/[[NSMutableData alloc] initWithData:data];}- (void)loadDatafromServer{ NSURL *url = [NSURL URLWithString:mad:"http://mysite.com/data.xml"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [NSURLConnection connectionWithRequest:request delegate:self];}- (void)viewDidLoad{ [super viewDidLoad]; [self loadDatafromServer];}\[/code\]
 
Top