I am developing one iPhone app开发者_运维知识库lication where I need to send some data (in XML format) from iPhone to server, on the server side I will parse that XML and get data for each XML node and than use them as per my requirement.
My question is:
- How will I form the XML file on iPhone?
- How will I send that XML file to server?
Which methods I will use.
Regards, Pratik
I'm not sure what kind of data you're putting in your XML file, but I'd just create it with an NSMutableString, then change it to an NSData when you're ready to upload it to the server.
create an NSURLRequest to your server and set the HTTPMethod to POST. Set the Content-Type to "multipart/form-data". Add the XML file to your HTTPBody setting it's MIME type as text/plain.
Here's some info on creating an NSURLRequest for uploading files: http://www.cocoadev.com/index.pl?HTTPFileUpload
Oh, and BTW, they encoded their data using NSASCIIStringEncoding, you'll want to change that to NSUTF8StringEncoding.
To form the XML file on iPhone, why don't you use KissXML?
To send the XML file to server, why don't you use ASIHTTPRequest (ASIFormDataRequest class)?
精彩评论