How to save to database through xml
I am calling a server side api which returns me the DB rows in xml format. I have parsed it. Then I edited the xml in iphone. Now I want to save the xml back to server with the changes. Then server side php script will parse the xml to save the changes to 开发者_如何学运维reflect in the database. My question is when I was calling the api , it was returning xml response. But how can I feed the xml to the api. I guess by constructing URL. If so what should I write HTTP request header? I think I have to use post method. I dont want to use SOAP, I want to use REST. Can anyone suggest any sample about this topic? Thanks Rupaanjaan
Create a request like this...
NSMutableURLRequest * request = [[NSMutableURLRequest alloc] init];
[request setHTTPMethod:@"POST"];
[request setURL:[NSURL URLWithString:your-url];
[request setValue:set-appropriate-value forHTTPHeaderField:@"Content-Type"];
[request setValue:set-value forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:NSData-object-holding-data-you-intend-to-post-on-server];
精彩评论