Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question 开发者_JAVA百科i want to store my data (which i am gathering through my app) to xml and then send it to my webspace. How should i do it??
Your question contains several tasks.
Here is a solution for the upload part:
On sever-side you need to have a file-upload.
On iOS-side I suggest the usage of ASIHttpRequest
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setFile:@"path/to/ur/xml" forKey:@"file"];
edit
Creating a (simple) XML-file should be quite easy, as it can be done just with String-operations.
- fill a (mutable) Array with the objects you want to write to the xml
- let's say, you have a collected address book data. you filled the array with Contacts objects
- each contact has n addresses, that are stored in an array, a name,...
- take the last object in the array
- write
<contact name="%@">
to a string, with passing in the contacts name - loop over the addresses and write
<address kind="%@">
with specifying kind as "work", "private", "other" - do similair with the address data (street, city,...)
- when done with a adress write
</address>
- when done with a contact write
</contact>
- remove last contact from array
- if the array isnt empty, start again with 2.
- wenn done with all data in the array, add
<adressbook>
in the beginning of the string and</addressbook>
at the end.
精彩评论