Getting information from an online database with iOS - iphone

I'm trying to query the ncbi public database. When I look at the network stream, all I can see is that the response header is text/html. Does that mean I have to parse the text/html in iOS to get the information I want in a database? Thanks.

If you are getting data in the form of a HTML document, you will indeed have to parse the HTML to extract the data.

Related

http POST vs GET request for getting a document sending a XML file

I know for getting a data we have to use a GET request. But this time I have to send a XML document (who will not be stored) for getting the data. What are the best practice in this case ?
You need send a xml document to your end-point to get your interested data.
As you need a xml doc, it has to be a POST REST end-point. (On a side note, sending any file contents as part of GET parameters is a bad design practice.)

How to deal with this situation building a REST API?

I got this problem, I have built a rest api and I don't know how to deal with this:
When the javascript client (Marionette.js) is in charge of making the views, I don't have problems, because as it is known, it just requests an url (e.g. example.com/user/37), the server retrieves a json with {id:'37', name:'Peter', age:'24'} (there is one controller class named User) and Marionette shows that data in the view. But if the user enter to example.com/user/37 by the browser it will show just {id:'37', name:'Peter', age:'24'} without any view. What can I do if I want to see the same view in both cases?
If you're trying to serve up HTML or JSON from the same endpoint then your server should be making that decision based on the request's Accept header. If the request's Accept header is application/json then your server should return just the JSON ortherwise return the HTML.
You can see that SoundCloud uses the same technique for returning XML or JSON from their API:
Resources are returned as XML by default, or JSON if a .json extension is appended to the resource URI. We encourage you to use JSON. You can also send an appropriate Accept header specifying the format you would like. For example, a request with the header Accept: application/json will return resources represented as a JSON document.
What you are trying to do is pratically impossible.
why ?
When your first enter the url example.com it's the server that responds with all the artifacts that compose your application (html, js, css ...) and the browser display it.
Now, when you enter ther url example.com/user/37 the server only sends the JSON data without any html, js or css, so the browser display the raw data he received.
What you are trying to do is to force the server to give two responses (JSON or html/js/css) depending on the user request.
You can do it, but it would be so complicated that's not worth the efforts.

Json Parsing Problem with Dotnet webserivces

I am posting some values to dotnet webservice.For this i am using AsiFormDataRequest.Values are posted suceesfully but coming response is in xml format. so iam not able to get the success or failure message in json format.
What i want to do for getting json response after posting to server.
Thanking in advance.
You need to configure the server to respond with JSON instead of XML. There is nothing you can do about this from within your app. If you don't have control over the server then you need to forget JSON and parse the XML instead.

Post JSON data to Facebook

In the app, I want to post a photo, and some text. I am able to post if I am using local stored data in resources but when data (in JSON format) is coming from server at the run time, I am not able to post that image and text which is coming from server in the JSON format.
Is there any way to post data at the runtime or I have to store the data at the client side, but in that case, the app will be bulky because data could be different at different locations?
I am not sure but you may be asking about posting an image using a URL instead of assuming data is local. If so, see this blog post - https://developers.facebook.com/blog/post/526/ and it introduced the ability to post an image by passing in a "url" parameter through the Graph API.

post xml from iphone to server

How can I post XML data format to server?
(I only know post paramters to server)
Thank you!
It will depend on the server. You could get the NSData -bytes representation of the XML data and, if you're working with a RESTful web application, use PUT or POST when sending the data.