pratik
pratik

Reputation: 4489

iPhone + sending data from iPhone to server as XML format

I am developing one iPhone application 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

Upvotes: 5

Views: 2664

Answers (2)

tomute
tomute

Reputation: 2653

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

Upvotes: 1

Arlen Anderson
Arlen Anderson

Reputation: 2496

  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.

Upvotes: 3

Related Questions