I'm using the following script to read an external RSS feed and output news on a website I'm working on:
<?php
$rss = new DOMDocument();
$rss->load('http://www.somewebsite.com/news/rss.xml');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 8;
$count = 1;
?>
<?php for ($x=0;$x<$limit;$x++) : ?>
<?php
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
?>
<section class="grid_3">
<div class="content">
<span class="date"><a href="<?php echo $link; ?>"><?php echo $date; ?></a></span>
<h6><a href="<?php echo $link; ?>"><?php echo $title; ?></a></h6>
</div>
</section>
<?php $count ++; ?>
<?php endfor; ?>
It worked fine the other day, but now I've had another look it's bringing up a load of errors along the lines of:
Warning: DOMDocument::load() [domdocument.load]: PCDATA invalid Char value 31
As well as this, the dates of the posts are showing up as
Thursday January 01, 1970
Does anyone know what might be wrong? Could this be something to do with the external RSS feed? That still looks fine when viewed in my browser though