0
我想從這個YouTube XML文件中提取數據 - http://www.youtube.com/feeds/videos.xml?user=latenightPHP的SimpleXML - 獲取從Youtube XML數據文件
我可以通過使用此代碼
<id>yt:video:dLUfTS4TxrQ</id>
<title>Sia: Cheap Thrills</title>
<published>2016-01-28T20:04:03+00:00</published>
$feed = simplexml_load_file("http://www.youtube.com/feeds/videos.xml?user=latenight");
echo $feed->entry[0]->title;
echo $feed->entry[0]->id;
echo $feed->entry[0]->published;
你如何解壓得到的易位 中的數據媒體:縮略圖,媒體:描述,媒體:starRating,媒體:統計信息使用PHP SimpleXML?
<media:group>
<media:title>Sia: Cheap Thrills</media:title>
<media:content url="https://www.youtube.com/v/dLUfTS4TxrQ?version=3" type="application/x-shockwave-flash" width="640" height="390"/>
<media:thumbnail url="https://i1.ytimg.com/vi/dLUfTS4TxrQ/hqdefault.jpg" width="480" height="360"/>
<media:description>
Music guest Sia performs "Cheap Thrills" for the Tonight Show audience. Subscribe NOW to The Tonight Show Starring Jimmy Fallon: http://bit.ly/1nwT1aN Watch The Tonight Show Starring Jimmy Fallon Weeknights 11:35/10:35c Get more Jimmy Fallon: Follow Jimmy: http://Twitter.com/JimmyFallon Like Jimmy: https://Facebook.com/JimmyFallon Get more The Tonight Show Starring Jimmy Fallon: Follow The Tonight Show: http://Twitter.com/FallonTonight Like The Tonight Show: https://Facebook.com/FallonTonight The Tonight Show Tumblr: http://fallontonight.tumblr.com/ Get more NBC: NBC YouTube: http://bit.ly/1dM1qBH Like NBC: http://Facebook.com/NBC Follow NBC: http://Twitter.com/NBC NBC Tumblr: http://nbctv.tumblr.com/ NBC Google+: https://plus.google.com/+NBC/posts The Tonight Show Starring Jimmy Fallon features hilarious highlights from the show including: comedy sketches, music parodies, celebrity interviews, ridiculous games, and, of course, Jimmy's Thank You Notes and hashtags! You'll also find behind the scenes videos and other great web exclusives. Sia: Cheap Thrills http://www.youtube.com/fallontonight
</media:description>
<media:community>
<media:starRating count="16185" average="4.86" min="1" max="5"/>
<media:statistics views="648221"/>
</media:community>
</media:group>
[SimpleXML:使用包含名稱空間的XML的可能的重複](http://stackoverflow.com/questions/2014835/simplexml-working-with-xml-containing-namespaces) – michi