views:

153

answers:

3

Hi,

I am reading an data from an XML file for my iPhone application. This data contains html tags such as <p></p> <strong> <B>, etc in it. By using NSString class can i remove these tags and format the display of the text as needed.

For example, if text inside the <p> </p> i want to display it in next paragraph. Is it possible?

Please suggest.

Any help would be appreciated.

-Sathiya

A: 

Mmm... Only me doesn't see an example? But you can insert @"\n" to move text to the next line in your UITextView or console.

Morion
A: 

There is a library on the iPhone to do HTML parsing, but it takes a bit more work than using NSString. However, it will give you a lot more control. You can walk the HTML tree and pick out the parts that interest you.

Look at libxml2's html reader:

http://xmlsoft.org/html/libxml-HTMLparser.html#htmlReadMemory

Jeremy Bower
+1  A: 

Why not leave the formatting in place, and use either a UIWebView to display the text or a TTStyledTextLabel from the Three20 project.

Kendall Helmstetter Gelner