How to solve - Node no longer exists

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anjshr7
Forum Newbie
Posts: 19
Joined: Fri Jul 17, 2015 1:28 pm

How to solve - Node no longer exists

Post 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;
}

?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to solve - Node no longer exists

Post 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?
Post Reply