Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Fatal error: Call to undefined method SimpleXMLElement::attribute()

xml php

This topic has been archived. This means that you cannot reply to this topic.
No replies to this topic

#1 anjshr7

anjshr7

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 20 July 2015 - 10:34 PM

Fatal error: Call to undefined method SimpleXMLElement::attribute() in D:\Program Files\wamp\www\New folder\ndtv_news.php on line 13

How to define method .....

<?php
//fetches articles from NDTV news RSS feed
function fetch_news(){

$data = file_get_contents('http://feeds.feedburner.com/News-TN');
$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->attribute() 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;
}

?>






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download