I am trying to customize some XML output. I've got things almost dialled, except when I try and wrap $node->body in the following code:

  $xml_elements = array(
      'key' => 'reason_for_donating',
      'value' => html_entity_decode ( '<![CDATA[' . strip_tags ($node->body) . ']]>'),

it comes up in View-source as :


 <reason_for_donating>&lt;![CDATA[Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis hendrerit commodo eros. Vivamus ut purus ac sem interdum eleifend. Aenean urna magna, mattis nec, ullamcorper a, semper in, tellus. Nam non eros. Nulla consectetuer, mi vehicula malesuada tincidunt, magna quam eleifend orci, id egestas leo felis sodales neque. Praesent id neque. Pellentesque pellentesque ipsum non nisi. Praesent rutrum dapibus metus. In nec nisi at leo cursus tincidunt. Praesent molestie augue ut nibh. Ut laoreet dui quis orci.
 <pubDate>Thu, 26 Jun 2008 11:58:50 -0400</pubDate>

 <guid isPermaLink="false">2 at http://www.xxx.www/</guid>

and I am left with the < and > around the cdata...

How do I get this to output properly?

Thanks for the help.




nimzie’s picture

I'm sure this can't be a terribly uncommon issue to run in to .. can anyone assist please?

nimzie’s picture

I am still stumped... So - has no one used content template to output RSS/XML feeds and use node->body as a CDATA type to pass along?

This is exactly what I am seeking in solution.

Thanks for your help.


lordgilman’s picture

subscribing to this issue

nimzie’s picture

I've worked away and found a solution, however the one I used requires a core hack...

If you want to hack the core files, then you can change the following line in the format_xml_elements() function in "includes/common.inc", around line 922.

$output .= '>'. (is_array($value['value']) ? format_xml_elements($value['value']) : check_plain($value['value'])) .'\n";

To this:
$output .= '>'. (is_array($value['value']) ? format_xml_elements($value['value']) : ($value['exact'] ? $value['value'] : check_plain($value['value']))) .'\n";

Then, in your RSS contemplate settings, add the 'exact' variable to the appropriate array:
'key' => 'xml_element_name',
'value' => html_entity_decode ( 'body) . ']]>'),
'exact' => true,

That got me by... Perfectly.