PHP
$rss = new DOMDocument();
$rss->load('http://www.autoexpress.co.uk/feeds/all');
$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,
'image' => $node->getElementsByTagName('whattagdoiaddhere')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 3;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l F d, Y', strtotime($feed[$x]['date']));
echo '<div class="news-row-index">';
echo '<div class="img"><a href="'.$link.'" target="_blank" title="'.$title.'"><img src="'.$image.'" height="79" width="89"></a></div>';
echo '<div class="details-index"><p><h5><a href="'.$link.'" target="_blank" title="'.$title.'">'.$title.'</a></h5><br />';
echo '<small><em>Posted on '.$date.'</em></small></p>';
echo '<p>'.$description.'</p></div>';
echo '</div>';
}
- I am trying to get the images from this rss but don't know exactly how to get the image and add it into the
<div class="img"
. - Also i have a problem because the image is being received but it's located in the
$description
variable. - Tried searching and found php rss feed show images but when i add the code from that answer I get nothing in the rss module. Please help me I really appreciate it.