属性を取得しようとしてい$xml->entry->yt:statistics->attributes()->viewCount
ます。SimpleXML でいくつか試してみましたが、実際には機能しません。
試み #1
<?php
$xml = simplexml_load_file("http://gdata.youtube.com/feeds/api/videos?author=Google");
echo $xml->entry[0]->yt:statistics['viewCount'];
?>
試み #2
<?php
$xml = simplexml_load_file("http://gdata.youtube.com/feeds/api/videos?author=Google");
echo $xml->entry[0]->yt:statistics->attributes()->viewCount;
?>
どちらも空白を返しますが、SimpleXML は機能していますが、フィードのタイトルを取得しようとしましたが、うまくいきました!
何か案は?
SOや他のサイトで他の例をたくさん見てきましたが、どういうわけかこれは機能していませんか? PHP は ':' をカットオフとして認識しますか、それとも私は何かばかげたことをしているだけですか?
ありがとうございます。