views:

75

answers:

2

I want to set up an app which can get the information from a particular web page. Then i display the value which got from that page to the iPhone user.

Detail:In the webpage on server ,there is the schedule for bus time. If the user input origin and terminus then show the user the time information(list on webpage) in a label. That's all.

What i have finished is : Open the iphone app, input two value(origin and terminus) to UITextField. Send the URL to server. Get the page, and show in UIWebView. What my problem next is how should i get the information form that page into another two labels to give the user about the bus time.

I have store data in my Array receiveData: self.receivedData = data;

I am not clear the data i received is XML or what? And how should i pick-up the value i want. (should i save the value to property list and the read the value?)

Thank you so much!

+2  A: 

Convert NSData to NSString then NSLog it and you can find the information you want.

if it is in xml, use some xml libs such as Touchxml.

if it is in html, google and try to find some code for striping HTML.

owen
Thank you.I am sure the page is XML. but when i convert to string , show me html format:NSMutableString *string =[[NSMutableString alloc] initWithData:data encoding:1]; Do you know why? thank you
Thank you , got it.
Use the browser to see what the real format it is.it should be the same with the string you get from initWithData.....
owen
A: 

You can convert the NSData response to NSString [[NSMutableString alloc] initWithData:data encoding:1]; You can check whether the response is XML or any other format and then extract the information you need.

Hetal Vora
i use your function to test, but what i get is html format(server page is XML), do you know the reason. thank you!
Thank you ,get it.