2017-03-07 8 views
1

このXMLファイルの最新のエントリのビューにアクセスするにはどうすればよいですか?XMLファイルのPHPアクセス値

私が試みている

https://www.youtube.com/feeds/videos.xml?channel_id=UCeNdjxcrWI5B1-j8mG4Nm7g

が、それは働いていない:

$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;}} 
+1

あなたはあなたのコードの残りの部分を投稿することができますか? – FatBoyXPC

+0

今すぐ変更する必要があります! – BlackWolve

答えて

1
<?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); 

・ホープ、このことができます;)

+0

それは動作します!どうもありがとう。 – BlackWolve

+0

答えとしてマークアップv ...コーディングをしてください:) –

関連する問題