views:

54

answers:

1

how to convert a HTML string to a plain text in iphone dev. Is there any in built functions which does it ?

I am actually downloading a html string from web and showing it in the UIwebview and i am giving the user a edit option so that the html needs to converted to tet so that user can edit

Thanks...

+1  A: 

It depends how you're downloading the HTML.

I would suggest that you use NSURLConnection and NSURLRequest to form a HTTP GET request and download the HTML that way.

You should implement the delegate methods for NSURLConneciton. You shoudl allocate an NSMutableData object to store the data you download, and append new data to it in -connection:didReceiveData:

Then once -connectionDidFinishLoading: is called, you can convert your NSData object into an NSString using

[[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding];

This will give you the raw HTML of the page, which you can then push into a UIWebView, using loadHTMLString:baseURL: or pass into a UITextView with setText: for editing.

Jasarien