开发者

Store data to xml in my app [closed]

开发者 https://www.devze.com 2023-01-16 23:53 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this
Closed. This question needs to be more focused. It is not currently accepting answers.

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.

  1. 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,...
  2. take the last object in the array
  3. write <contact name="%@"> to a string, with passing in the contacts name
  4. loop over the addresses and write <address kind="%@"> with specifying kind as "work", "private", "other"
  5. do similair with the address data (street, city,...)
  6. when done with a adress write </address>
  7. when done with a contact write </contact>
  8. remove last contact from array
  9. if the array isnt empty, start again with 2.
  10. wenn done with all data in the array, add <adressbook>in the beginning of the string and </addressbook> at the end.
0

精彩评论

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