Is there a way to verify / validate a remote开发者_高级运维 XML (or download it first and store it locally) before processing it and store the info into CoreData or DB with iPhone SDK 3?
In Cocoa you can just download it
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30];
NSData *urlData;
NSURLResponse *response;
NSError *error = nil;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
and load it into a NSXMLDocument
NSXMLDocument *doc = [[NSXMLDocument alloc]
initWithData:urlData options:0 error:&error];
and get the nodes with
NSArray* tempArray = [doc nodesForXPath:@"something/anotherthing" error:&error];
Don't know if all of this works on the iPhone.
精彩评论