Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XML文件的PHP访问值_Php_Xml_Youtube - Fatal编程技术网

XML文件的PHP访问值

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文件中最新条目的视图

这是我的尝试,但不起作用:

$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);