tags:

views:

41

answers:

2

In my application i need to create and save data into an xml file on my webspace and then i want to parse that xml into my iphone app. The question here is this is being done by two different parties a sender and a receiver. But i don;t know how to parse that xml file into my app when i don't have the excat url of that xml because there will be number of people who will be using this app so how i can allocate the xml a specific url and pass that url at receiver end.

Thanks,

+1  A: 

As there is a lot to this question I can only give you a vague answer to keep it short. The type of communication I recommend using is NSURLConnection. That will allow you to get the contents of say an xml from a URL.

As far as identifying individual users there is a few ways all of them a fair bit of work. You could create a sign in where the user has a unique username or email. Store that in the database on your server and pass it as part of the url.

You could also sort of use push notification registration where your server is required to keep an iPhone unique identifier to push information to Apple. I don't know enough to push notification to give you much guidance in this but if you don't want the user to create an account I think this would be the way. You could also query the server for a unique ID and store it in NSUserDefaults.

I would recommend the user account creation though. Also have a look at NSXMLParser for your xml parsing.

Beyond this help ask a more specific question. There are also many other ways to do this, its just the way I do it.

Rudiger
OK so suppose if i want to send an xml file from device to another and the xml file has images, text and map with annotation. Can i have total control over the xml file at receiver's side. I mean whether i ca fetch the data from xml and display it in my app as i want. Thanks for your answer.
Ashutosh
You don't wan't to send images and maps with annotations over xml. If you REALLY wanted to you could encode it as base64 but that would be an epic amount of data to transfer. When you do an NSURLConnection you can send straight data as variables that the server can pickup using POST. No offence but this project doesn't seem like its been thought through well for mobile. Why are you passing a map with annotations? Can't you send the coordinates of the annotations and location of the map through xml and get the device to interpret it?
Rudiger
Btw, it is impossible to push the xml data you want to an iPhone. The way you get around this is to push a small amount of data to the device via push notifications that tells your app to request the larger amount of information from the server.
Rudiger
A: 

I can help you with the parsing of the XML.

iOS (like mac) has a built in XML parser.

Still I would recommend you use an external library, there are several available out there.

In a recent project, I very successfully used TouchXML: http://github.com/schwa/TouchXML

Here is a very simple tutorial on how to use the TouchXML library to parse XML files:

http://foobarpig.com/iphone/parsing-xml-element-attributes-with-touchxml.html

Zebs