Edit corrupted html (& lt;) to fix one (<)

I have saved the html code in a variable NSString

to display in UIWebView

its work fine, but sometimes I get wrong syntax like this

<body>&lt;h3&gt;Hazem Taha Ghareeb &lt;small&gt;report&lt;/small&gt;&lt;/h3&gt;From: &lt;p&gt;2014-06-02 &lt;/p&gt; To: &lt;p&gt;2014-06-16 &lt;/p&gt;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Exam&lt;/th&gt;&lt;th&gt;Date&lt;/th&gt;&lt;th&gt;Result&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3&gt;Absence&lt;/h3&gt;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Date&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;

      

it should be like

<body><h3>Hazem Taha <small>report</small></h3>From: <p>2014-08-01 </p> To: <p>2014-08-05 </p><table><thead><th>Exam</th><th>Date</th><th>Result</th></thead><tbody><tr><td>Math exam </td><td>2014-08-03 </td><td>94 </td></tr></tbody></table><h3>Absence</h3><table><thead><th>Date</th></thead><tbody><tr><td>2014-08-04 </td></tr><tr><td>2014-08-05 </td></tr></tbody></table></body></html>

      

how can i fix it

Content is a file containing my html style

NSString * myPath= [[NSBundle mainBundle] pathForResource:@"content" ofType:@"txt"];
    NSString *fileContent = [[NSString alloc]initWithContentsOfFile:myPath encoding:NSUTF8StringEncoding error:nil];
    fileContent = [fileContent stringByAppendingString:reportBody];
    NSLog(@"content file %@",fileContent);
    [web loadHTMLString:fileContent  baseURL:[NSURL fileURLWithPath:myPath]];

      

+3


source share





All Articles