0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I think the asker rather meant how to render the html output into plain text, i.e. translating <br> into a CR/LF, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.