开发者

iPhone + sending data from iPhone to server as XML format

开发者 https://www.devze.com 2022-12-17 01:42 出处:网络
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 an

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:

  1. How will I form the XML file on iPhone?
  2. How will I send that XML file to server?

Which methods I will use.

Regards, Pratik


  1. 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.

  2. 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)?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号