Click to See Complete Forum and Search --> : non-breaking space in rss feed


chrisb
06-12-2007, 08:07 AM
Hi All,

I have a question about my RSS feed. Say I have a non-breaking space in the form   saved in mysql database it crashes the RSS feed when I try and output the data.

How would it change   to just a plain &

Would it be using htmlspecialchars? Ie:


$rssValue .= "<title>" . htmlspecialchars($row['headline'], ENT_QUOTES) . "</title>\r\n";


Or is it done using the character encoding ie:


$rssValue = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\r\n";
$rssValue .= "<rss version=\"2.0\">\r\n";


Or have I misunderstood? How would/can it be done?

Thanks

Chris

NogDog
06-12-2007, 02:13 PM
htmlspecialchars() would turn &nbsp; into &nbsp;nbsp;, which obviously won't help. I'd probably leave it as it is, but encapsulate the data in CDATA tags:

$rssValue .= "<title><![CDATA[" . $row['headline'] . "]]></title>\r\n";

chrisb
06-12-2007, 03:15 PM
Thanks - helps a lot! ;-)