Hi everyone!
Like in the title: how can i download and save an xml file?
Because i know how to read, download and save the data in a "NSUserDefaults" file... but TBXML (the API that i'm using for parse the xml) need a real path, not a variable NSUserDefaults!
This is my code:
Code:
NSError *err = [[[NSError alloc] init] autorelease];
NSString *url = [[NSString stringWithFormat:@"www.hello.com/hello.xml"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *myTxtFile = [NSString stringWithContentsOfURL:[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error:&err];
if(err.code != 0) {
//HANDLE ERROR HERE
}
//save
[[NSUserDefaults standardUserDefaults] setObject:myTxtFile forKey:@"MyFile"];
now, TBXML need this code:
Code:
TBXML *tbxml = [[TBXML tbxmlWithXMLFile:@"hello.xml"] retain];
how can i save my online-xml in a offline-xml?
thanks