1
<item>
<data>
  <![CDATA[
  <p>Test</p>
  <p><strong>Hi!</strong><br />Hello.</p>
  ]]>
</data>
</item>

Using TouchXML/NSXMLParser How can i extract only the HTML part into a string/appropriate data format so that I can display it in a UIWebView?

It's definitely possible: http://code.google.com/p/touchcode/issues/detail?id=36&can=1&q=cdata

Dot
  • 439
  • 5
  • 17
  • No XML parser should parse CDATA sections anyway http://www.w3schools.com/xmL/xml_cdata.asp – Martin Labuschin Jan 21 '10 at 15:13
  • CDATA is the only way you can store HTML or other data containing "<" and "&" characters, I think what the link means is that the parser should not *automatically* parse the node as a normal node. CXMLNode is implemented so that it can handle parsing CDATA. – Dot Jan 21 '10 at 15:21
  • You can certainly store literal `<` and `&` without a CDATA section, through normal `&`-escaping. You should read the textual content of the ``, not caring whether it came from inside a CDATA section or just plain text. – bobince Jan 21 '10 at 16:46
  • Get the CDATA element, get everything inside and display in UIWebView ? – stefanB Jan 21 '10 at 22:36
  • @bobince Yes indeed!... HTML encoded (») works too! @stefanB yes, actually thats what I'm trying to do... – Dot Jan 22 '10 at 09:35

1 Answers1

3

TouchXML will parse it automatically. If you retrieve the stringValue of the CXMLElement you will get the full "raw" html back, properly formed.

Marcus S. Zarra
  • 46,571
  • 9
  • 101
  • 182
  • Indeed! Automatic CDATA parsing and clean HTML into NSString to put it into UIWebView use `[myWebView loadHTMLString:myHTMLString baseURL:[NSURL URLWithString:@"http://www.mysite.com"]];` – Dot Jan 23 '10 at 21:59