0

I am developing an app which reads data from SharePoint list into an array. I am at the point of displaying this data on screen as text fields. However one of the imported data fields is formatted in html markup code e.g.

<div class="ExternalClass7E8EC81DFF944C7BB81DA896086ABDFF"><p> </p>
<div><span style="font-size:12pt"><font face="Calibri">Project Completion Date (A05-A07) <span>  </span><span>  </span>15<sup>th</sup> May 2012</font></span></div>
​ <p> </p></div>

Does anyone know how I could go about extracting the text content from this? Alternatively perhaps I should be looking at displaying this data as a web page on screen? If so could someone point me in the right direction please?

Many thanks in advance for your help...

1 Answer 1

2

The HTML as posted is encoded with "entity" codes. So, the first task is to decode those to get back to actual HTML. You can use CFXMLCreateStringByUnescapingEntities() for that.

You can create an NSXMLDocument from the result with the NSXMLDocumentTidyHTML option. You can request the -stringValue of that to get the plain text.

Alternatively, you can create an NSAttributedString with -initWithHTML:documentAttributes:.

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

2 Comments

Thanks Ken. I have decided to go down the display as a web page route, using 'loadHTMLString'. I have passed the previously mentioned data through to a new view, but it is displaying as html and not rendering as a web page. Any clues how I can render it correctly from this point? Thank you.
OK I have finally sorted it - using MREntitiesConverter to decode HTML to remove entities, and then loadHTMLString to render the pure html code on the screen as a web page.

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.