0

First I parse XML and retrieve this:

<p><strong>Berns Salonger - the City's

The I decode it with MWFeedParser (stringByDecodingHTMLEntities) and retrieve this:

<p><strong>Berns Salonger - the City's Ideal Meeting Place 

Note that this is only one line of many many lines which includes alot of
tags.

Then I replace
with \n and the console writes out the text with new lines. Everything is great except that all the other HTML tags is still there.

So I then run stringByConvertingHTMLToPlainText and all HTML tags dissapears. But also my replaced new lines.

How can I decode HTML without and at the same time replace
with \n to print out a nice formatted text in a UITextView?

Fernando Redondo
  • 1,557
  • 3
  • 20
  • 38

1 Answers1

1

Instead of replacing <br> with \n, try replacing it with an HTML entity for newline: &#10;. Then, when you call stringByConvertingHTMLToPlainText, it will convert the entity to an actual newline character.

Josh Hinman
  • 6,745
  • 7
  • 38
  • 47
  • If I want to replace

    and

    ? I can't fint the HTML entity for that. I thought it was ΒΆ but it wasn't.
    – Fernando Redondo Sep 28 '10 at 12:06
  • I tried with: contentText = [contentText stringByReplacingOccurrencesOfString:@"

    " withString:@"<p>"]; contentText = [contentText stringByReplacingOccurrencesOfString:@"

    " withString:@"</p>"]; But that didn't work either.
    – Fernando Redondo Sep 28 '10 at 12:17
  • Use the same entity for

    : Maybe use two of them for double spacing.

    – Josh Hinman Sep 28 '10 at 19:33