XML文件的PHP访问值
如何访问此XML文件中最新条目的视图 这是我的尝试,但不起作用:XML文件的PHP访问值,php,xml,youtube,Php,Xml,Youtube,如何访问此XML文件中最新条目的视图 这是我的尝试,但不起作用: $xml = simplexml_load_file(sprintf('https://www.youtube.com/feeds/videos.xml?channel_id=%s', $channel_id)); foreach ($xml->entry as $entry) { if (!empty($entry->children('yt', true)-
$xml = simplexml_load_file(sprintf('https://www.youtube.com/feeds/videos.xml?channel_id=%s', $channel_id));
foreach ($xml->entry as $entry) {
if (!empty($entry->children('yt', true)->videoId[0])){
$views = $entry->children('group')->children('community')->statistics['views'];
echo $views;}}
entry->children('media',true)->group->community->statistics->attributes()->视图);
希望这有帮助;) 你能发布你剩下的代码吗?现在应该更改了!
<?php
$url = 'https://www.youtube.com/feeds/videos.xml?channel_id=UCeNdjxcrWI5B1-j8mG4Nm7g';
$xml = new SimpleXMLElement($url, null, true);
print_r($xml->entry->children('media', true)->group->community->statistics->attributes()->views);