I want to get image URL from RSS feed, but I only can get title, url link, and description. Here is the feed link "http://www.hotkhmer.com/feeds/posts/default?alt=rss" . And here is my code:
function parse(){
$rss = simplexml_load_file($this->feed);
$rss_split = array();
foreach ($rss->channel->item as $item) {
$title = (string) $item->title; // Title
$link = (string) $item->link; // Url Link
$description = (string) $item->description; //Description
$rss_split[] = '
<div>
<a href="'.$link.'" target="_blank" title="" >'.$title.'</a>
<hr>
</div>
';
}
return $rss_split;
}
Well as far a I can see there is no image element in the feed. The image is in the description
if that is what you are after you are going to need to use html_entity_decode
and then parse that with something like the php DOMDocument
class to get the image tag out of it.
There is also an image in there with the tag thumbnail
. Use that and then retrieve the url
attribute using the array that element->attributes()
returns.
It really does not make it easy that the xml you provided is minified...