<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>