Quantcast
Channel: RSS feed not validating because of substr cutting html characters - Stack Overflow
Viewing all articles
Browse latest Browse all 5

RSS feed not validating because of substr cutting html characters

$
0
0

Currently unable to get my rss feed to validate through W3C RSS Validator. It seems there's a problem with the time/date. If you click the W3C link it'll show the errors. When I comment out the date it works fine but the date is kinda crucial!!

Here's the original script:

  include "db.php";  header("Expires: 0");  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  header("cache-control: no-store, no-cache, must-revalidate");  header("Pragma: no-cache");  header("Content-type: text/xml");  print "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";?><rss version="2.0"><channel><title>MediWales Events</title><description>The latest Events, updates and announcements from MediWales.</description><link>http://www.mediwales.com</link><copyright>Copyright 2011 MediWales.</copyright><docs>http://blogs.law.harvard.edu/tech/rss</docs><language>en-us</language><lastBuildDate><? print date("D, d M Y H:i:s"); ?> 0000</lastBuildDate><managingEditor>info@mediwales.com</managingEditor><pubDate><? print date("D, d M Y H:i:s"); ?> 0000</pubDate><webMaster>info@mediwales.com</webMaster><generator>codeworks rss script (1.0.0)</generator><image><url>http://mediwales.com/login/uploaded/template/logo.png</url><title>MediWales Website</title><link>http://www.mediwales.com</link><description>The latest Events, updates and announcements from MediWales.</description><width>144</width><height>52</height></image><?      $latestnews = mysql_query("SELECT myevents.*, myevents_dates.datefrom from myevents, myevents_dates WHERE myevents_dates.datefrom >= CURDATE() AND myevents.id = myevents_dates.eventid order by myevents_dates.datefrom");          while ($news = mysql_fetch_assoc($latestnews)) {              $datetime = explode("",$news[datefrom]);              $date = explode("-",$datetime[0]);              $time = explode(":",$datetime[1]);              $news[description] = strip_tags($news[description]);              $news[description] = htmlspecialchars($news[description]);              echo "<item>";              echo "<title>".mb_convert_encoding(htmlspecialchars($news[title]),"US-ASCII")."</title>";              echo "<description>".mb_convert_encoding(substr($news[description],0, 250),"US-ASCII")."</description>";              echo "<link>http://www.mediwales.com/index.php?id=4&amp;nid=$news[id]</link>";              echo "<pubDate>".date('D, d M Y H:i:s O', mktime($time[0],$time[1],$time[2],$date[1],$date[2],$date[0]))."</pubDate>";              echo "</item>";          }  ?></channel>  </rss>

Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images