How to get data from MySQL generated XML? - iphone

I have an app to send data from iPhone to MySQL server and I got it with request from objective-c and php on server.
Now, I want to receive data from server by XML. I have created a php code to generate data from MySQL to XML. How can I code in objective-c to call this php code? The goal is using this XML to parse and display on iPhone (I have objective-c code to parse xml file from link on server).
Please help me if you know and used to work on that.

Use Web-servces Like XML- RPC, SOAP ,REST
To connect to a mysql database, your best bet is to use JSON/SOAP/XML/PHP or some combo of the mentioned, to talk between your database and your app..
The reason database connection directly from the device is a bad idea, is that you have to enable global external access to it for it to work. You can keep your data safer by having scripts on your server do the communication to the database.

Your server needs to expose a service of some kind (a URL the iPhone app can call).
Your app can call this URL with NSURLConnection (or lots of others).
This will return you an NSData * object.
Your app will then need to parse this raw data into XML (or JSON or a few others). You can use NSXMLParser (and lots of others) to do the parsing.
Then, you need to translate the XML into useful business objects.

Related

iphone data storage to remote SQL database server

I have a task at hand to create a iphone app which is required to do the following.
the app should get the data entered by the user and store it into a remote server database.
other app user can see the data in the remote database.
store login information of the user using the app so as to keep track of what information as uploaded and by who
the thing that i would like to know.
1) What SQL server database is best to accomplish the task.
2) what format is best to retrieve the information from the database.
3) how to send the data from the iphone to the remover server database to it can store the data.
i read up on SQLite and found out that this particular database is a offline which stores the data locally so it cannot be viewed by other used. i wan to use a SQL database which can be accessed remotely.
1) What SQL server database is best to accomplish the task.
For implementation on server side, you can implement any server database, it does not matter. For implementation on iphone device, you have to implement SQLite database, which will provide storage locally.
2) what format is best to retrieve the information from the database.
You can retrieve data using XML or JSON format which will be parsed in device and can be stored in SQLite database, it is the easiest way to transfer data between client and server.
3) how to send the data from the iphone to the remover server database to it can store the data.
You can send data from iphone to server in XML/JSON format or by passing parameters in POST or GET request method then this format is parsed on server side and store data on server database.
For all this, you will require to implement API on server side, which will be the interface between server and device.
I know you mention SQL specifically, but is this a requirement or just a choice based on what most other people are doing? I ask because personally I would give serious thought to using a NoSQL database (document store) like couchdb for such a task. Deploying couch means you often don't need server side application layer at all, the way you will for a SQL based solution.
You talk to couch using HTTP which is perfectly suited to the ASIHTTPRequest library for example. Fetching data is usually a GET request and storing documents is done with PUT. All the data in or out comes back as JSON so a good JSON library will make life easier.
The combination of couchdb and the 2 libraries linked above, makes developing a data driven application really, really easy.
That's how I would do it ...
If you really need to stick with SQL, then as Jignesh says, use whatever database you like and implement a suitable API in the server side language of your choice. You can transfer the data however you like although JSON would still get my vote as a relatively light protocol that remains human readable.
You can use a cloud-enabled database service, like windows azure.

Sending data to a server for computation

I want to create an application which will will be a webapp. I want to collect the data from the user, send it to a server where the computation will take place, and have the result displayed on the iPhone screen. The server normally takes results from a regular webpage via text fields and computes it and displays the result on the webpage. I just want the send the data via iPhone. Navigating my iPhone safari to the webpage is NOT an option, as the webpage is not optimized. So I how do I send data to the server, make it compute the results and have the results displayed on my iPhone?
Thank you.
Regards
EDIT:
I have no control over the server. Imagine my case to be as follows: The user enters a word, the word is sent by the iPhone to a Google server, the server compiles the search results and sends it back to my iPhone, and then the iPhone displays this result on the screen.Any more suggestions?
You might consider using ASIHTTPRequest/ASIFormDataRequest if you want to submit form data to your existing web page using form fields (per your description.)
In general I find ASIHTTPRequest friendlier to use than NSURLConnection / NSURLRequest.
http://allseeing-i.com/ASIHTTPRequest/
The most straightforward way is to use NSMutableURLRequest to create the GET or POST request, and then NSURLConnection to (asynchronously) send the data and receive the result. You could also use any number of third-party libraries to do the same thing.
As for the server side of things, you would have it accept a GET or POST just as you would with a web-based app, and output data in an appropriate format.
As for the output format that will be parsed by your app: With the standard classes, you can easily parse plist data and (with a little more work) XML; third-party libraries can be found to parse json and many other formats, if you so desire.

Is it possible to connect to SQL server in iPhone?

Is it possible to connect to SQL server in iPhone?. I want to create a new application and i want to retrieve the data from SQL Server and displayed. Previously it created using ASP.NET and SQL Server. Now my client wants to display the datas which is retrieved in SQL server data base. But the database contains the huge amount of data. So is it possible to convert the SQL Server to SQLite.(But SQLite is a light weight components). How can i do that? Can i use Web services? or i will ask to server side and convert the XML file and then i will use XML Parsing. I have no idea about it?
Please Explain Me!
Thanks.
i don't work on an iPhone app but i know that our guys that do use webservices that return pure xml with data, return that to the iphone and then parse that xml.
Wow... You are actually wondering if you can connect your iPhone-application to a SQL-server directly? Are you insane?! If you do, you need to connect with host-, username-, password-, en db-name-parameters. When people 'hack your binary converting it back to the source-code (.m-files)' they can read these parameters and create a custom connection to your db-server.
So, what you need to do is create a few scripts that parse your DB-data and return it as xml-data, so hackers won't be able to loggin into your db-server.

How to synch SQLite data to server in iPhone

I'm a total noob when it comes to iPhone development and have been tasked to create a database app that can download and upload sqlite data to and from a server via http using web services. So far I already have a form for retrieving and saving data to a SQLite database and now I need some information on how I can upload the SQLite data to a server. The SQLite database will only have one table with 3 columns and about 200 rows max. I hope somebody can point me to the right direction or lead me to some sample codes.
Appreciate any help.
As you are using HTTP to get data into the iPhone, you should also use HTTP to get data out of the iPhone. That way, you can query the SQLITE database and send the data through HTTP to a remote server.
It's pretty simple to accomplish since you have all the HTTP protocol implemented in the SDK.
On the server side, you can use whatever you want: Apache+PHP, Tomcat, JBoss, ASP.NET, you name it.

Update via XML or SQLite db file if possible?

I'm developing an app using UITableView driven content.
Current testing is done with local XML of size 100kb. This info should update about once every 2 months. The flow is reading pre-sorted XML -> convert to NSDictionary -> UITableView
Since parsing XML will take some work during load every time, plus table index, sorting and searching seems clumsy. So I have this idea about storing such info in a sqlite DB file
My real question is whether it's possible to download the entire sqlite DB file via http(s) instead of XML to update the info?
I don't understand the question...you have a sqlite database on a server somewhere and you want to know if it's possible to download via http? Yes, of course, just open a NSURLConnection and grab the data.
If you want to somehow transform XML from an http source to a sqlite database, well, then you'll have to write your own custom transformation code to get the proper SQL statements--there's no automatic way to do this in Cocoa.
You have a couple of options...
You can keep the stuff on the server
XML and build the database on the
fly.
You could post a text file on
the server with pre-canned insert
statements.
You could just have a
ready made DB file on the server and
download it.
Any would work... Some are more code than others.