Page 1 of 1

How to solve - Node no longer exists

Posted: Tue Jul 21, 2015 5:30 am
by anjshr7
I am getting this error on line 14 i.e foreach($media->attributes() as $key => $value)

Warning: fetch_news(): Node no longer exists in D:\Program Files\wamp\www\New folder\ndtv_news.php on line 14

Code: Select all

<?php
//fetches articles from NDTV news RSS feed
function fetch_news(){
   $attribute = 'http://feeds.feedburner.com/NDTV-LatestNews';

    $data = file_get_contents('http://feeds.feedburner.com/NDTV-LatestNews');
    $data = simplexml_load_string($data);

    $articles = array();
    foreach ($data->channel->item as $item){
    $media = $item->children('http://search.yahoo.com/mrss');
    $image = array();

    foreach($media->attributes() as $key => $value)
    {
        $image[$key] = (string)$value;
    }

$articles[] = array('title'=>(string)$item->title,
    'description'=>(string)$item->description,
    'link'=>(string)$item->link,
    'date'=>(string)$item->pubDate,
    'image'=>'$image');
}

return $articles;
}

?>

Re: How to solve - Node no longer exists

Posted: Tue Jul 21, 2015 6:28 am
by Celauran

Code: Select all

$media = $item->children('http://search.yahoo.com/mrss');
Where is that namespace coming from? Have you looked at the raw XML?