I am new to iphone development.I want to parse an xml page .The source code contains some htmls tags.This html tag is displayed in my simulator.I want to filter the tags and display only the content.The sorce code of xml is like
<description>
<![CDATA[<br /><p class="author"><span class="by">By: </span>By Sydney Ember</p><br><p>In the week since an earthquake devastated Haiti ...</p>]]>
</description>
I want “in the week since an …” to be displayed and not the html tags.Please help me out.Thanks
As said before in other answers, the data in your xml is inside a CDATA block – this means that when you get the contents of the tag, the XML parser won’t be able to get rid of the ‘By:’ bit for you – as far as it’s concerned, it’s all just text.
However,if you’re going to display it inside as HTML inside a UIWebView (instead of a UILabel etc), you can add a style sheet to the start of the string that makes the ‘By:’ hidden. Something like
where descriptionString is the contents of the
<description>tag in your xml.However this approach is a little heavy handed, I would try very hard to get some cleaner xml from your server!
As for actually parsing the xml, try the NSXMLParser object.