1
<entry> <id>yt:video:BpTW-7WGFVk</id> <yt:videoId>BpTW-7WGFVk</yt:videoId> <yt:channelId>UCqWTiyd9_A6oAOKHJkDOlZQ</yt:channelId> <title> Princess Lianna will meet Princess Cinderella | Kids Wish Network | Wish Granted | Kids Wish </title> <link rel="alternate" href="http://www.youtube.com/watch?v=BpTW-7WGFVk"/> <author> <name>Kids Wish Network</name> <uri> http://www.youtube.com/channel/UCqWTiyd9_A6oAOKHJkDOlZQ </uri> </author> <published>2015-08-18T15:09:32+00:00</published> <updated>2015-10-21T15:42:18+00:00</updated> <media:group> <media:title>...</media:title> <media:content url="https://www.youtube.com/v/BpTW-7WGFVk?version=3" type="application/x-shockwave-flash" width="640" height="390"/> <media:thumbnail url="https://i3.ytimg.com/vi/BpTW-7WGFVk/hqdefault.jpg" width="480" height="360"/> <media:description>...</media:description> <media:community> <media:starRating count="1" average="5.00" min="1" max="5"/> <media:statistics views="34"/> </media:community> </media:group> </entry> 

My question is: I understand how to parse the standard tags of <entry> or <title>, but I don't understand how to parse the data for <media:group> or <media:description>. The code below is what I am using to parse just the basic info for title, id and returning it.

function fetch_youtube_rss($cache_len = 3600) { $html = ""; $url = "https://www.youtube.com/feeds/videos.xml?user=KidsWishNetwork"; $xml = simplexml_load_file($url); for($i = 0; $i < 8; $i++){ $id = $xml->entry[$i]->id; $id = str_replace('yt:video:','',$id); $title = $xml->entry[$i]->title; $title = str_replace('| Kids Wish Network | Wish Kid | Hero','',$title); $link = "https://www.youtube.com/watch?v=".$id; $html .= "<div><h4><a href='{$link}' target='_blank'>$title</a></h4><iframe width='295' height='166' src='https://www.youtube.com/embed/".$id."?rel=0' frameborder='0' allowfullscreen></iframe></div>"; } return $html; } 

How can I update this to say include the description from <media:description>

4
  • 5
    Have you seen this thread, stackoverflow.com/questions/595946/…? Commented Mar 31, 2016 at 16:41
  • Looking at it now, thank you. It did not popup in my list of prev asked questions.. thank you! Commented Mar 31, 2016 at 17:08
  • Unfortunately, I don't understand it. I have tried to add that to my issue here, and it just creates fatal errors.. I've tried a few different ways, but nobody's example on that post has helped me. Thanks again Commented Mar 31, 2016 at 17:39
  • 2
    Okay just got it to work using a W3 schools lesson here - thanks for pointing me in the right direction - I'll update my code once I have it all working together. Commented Mar 31, 2016 at 17:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.