Jump to content

feed import


ravi181229

Recommended Posts

Hi,

 

I am trying to import a feed and read it using SimpleXMLElement.

first I found that it has extra characters at the beginning and at the end, so I wrote code which removes extra characters  :

$link = 'http://ustream.tv/live.rss';

$rss_feed = file_get_contents($link);

//$rss_feed = str_replace("utf-8", "iso-8859-1", $rss_feed);

$rss_feed = substr($rss_feed, 5);

$rss_feed = ltrim($rss_feed);

$rss_feed = substr($rss_feed, 0, -5);

$rss_feed = rtrim($rss_feed);

$ustream = new SimpleXMLElement($rss_feed);

$casts = $ustream->channel->item;

foreach ($casts as $cast) {

    echo "<br>Title:".$cast->title;

}

 

but still it displays error.

 

I need your help.

 

Thanks,

Ravi

Link to comment
https://forums.phpfreaks.com/topic/141844-feed-import/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.