Hello,
I have been working on a small piece of code for the last day or so, and I have gone through over one hundred resources, and frankly it's beaten me.
What I am attempting to do is pull a small bit of data from a XML file served through the youtube api.
I have am attempting to pull data from a xml file through a url like the below:
https://gdata.youtube.com/feeds/api/playlists/CA22CCE64DD2CCBE?v=2&max-results=1
The code should pull data about latest video from a selected playlist on youtube...
<?php
// FEED URL
$feedURL = 'https://gdata.youtube.com/feeds/api/playlists/CA22CCE64DD2CCBE?v=2&max-results=1';
// read feed into SimpleXML object
$sxml = simplexml_load_file($feedURL);?>
//Code to output a specific piece of data from the xml file
<?php echo $sxml->entry->{'media:group'}{'media:description'}; ?>
I have skimmed the fat off the xml file so you can see the piece of data easily that I am trying to output.
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007' gd:etag='W/"CUAFSH47eCp7I2A9WhJQEE4."'>
<entry gd:etag='W/"YDwqeyM."'>
<media:group>
<media:player url='https://www.youtube.com/watch?v=dCVmk66ldkE9w&feature=youtube_gdata_player'/></media:group>
</entry>
</feed>
I need my code above to pull the media:player url and echo it out in plain text form.
It's seems like I don't no my syntax for working with xml and I guess it's something simple.
If anyone can help I would be greatly appreciated.