Get data from XML file in PHP
$rss_link = "http://xyogasangeetax.api.channel.livestream.com/2.0/latestclips.xml"; //xml_file_link
$rss_feed_channel = $rss_feed->channel;
$rss_feed_channel_item = $rss_feed->channel->item
or
//$rss_feed = simplexml_load_file($rss_link, 'SimpleXMLElement', LIBXML_NOCDATA);
$rss_feed = file_get_contents($rss_link);
//mb_convert_encoding($rss_feed, 'UTF-16LE', 'UTF-8');
$rss_feed = new SimpleXmlElement($rss_feed);
$rss_feed_channel = $rss_feed->channel;
$rss_feed_channel_item = $rss_feed->channel->item
$context = stream_context_create( array( 'http' => array( 'follow_location' => false ) ) );
$content = file_get_contents("http://xyogasangeetax.api.channel.livestream.com/2.0/latestclips.xml", false, $context);
$data = new SimpleXmlElement($content);
foreach($data->channel->item as $entry)
{ if ($media = $entry->children('media', TRUE))
{ echo "<div style=\"width:160px;display:block;float:left;padding:15px;\">";
$attributes = $media->content->attributes();
$src = $play_attributes['url'];
if ($media->thumbnail)
{ $attributes = $media->thumbnail->attributes();
$imgsrc = (string)$attributes['url'];
echo "<img src=\"$imgsrc\" alt=\"\" \/>";
}
}
$pub_date= explode("-",$entry->pubDate);
echo date('F d,Y',strtotime(trim($pub_date[0])));
echo "</div>"; }
Comments
Post a Comment