Search code examples
iphonehtmlcdata

Ignore CDATA while xml parsing


I am new to iphone development.I want to ignore CDATA tag while parsing because it consider the HTML tag following it as text.Since i want to display the content alone ,i want my parser to ignore CDATA tag.My source code is

[CDATA[<br /><p class="author"><span class="by">By: </span>By Sydney Ember</p><br><p>In the week since an </p>]].

Is there any way to ignore CDATA tag? Is there any way to parse my source twice so it displays only the content?

Please give me some sample code.Please help me out.Thanks.


Solution

  • If you treat the CDATA content as XML instead of CDATA then your parser will throw an error (since your HTML is a weird mix of XHTML and HTML and is not well formed).

    If you want to get the HTML, then parse the XML, extract the text content of the node, then parse that text as HTML.