douhoulei4706 2010-10-25 20:24
浏览 45
已采纳

尝试解析YouTube搜索Feed时出错

I'm using SimpleXML to parse a YouTube search feed. I want to get the first result in the feed after searching for a term. Right now my code looks like this:

set_time_limit(0);

// Include needed files
require_once "config.php";

$xml = simplexml_load_file('http://gdata.youtube.com/feeds/base/videos?q=V.I.P.+KE%24HA&client=ytapi-youtube-search&v=2');

print_r($xml->entry[0]->link);

The output for the code above is:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [rel] => alternate
            [type] => text/html
            [href] => http://www.youtube.com/watch?v=TveGAmLdn8k&feature=youtube_gdata
        )

)

How can i get the value of "href" ?

Thank you.

  • 写回答

2条回答 默认 最新

  • dongye1942 2010-10-25 20:45
    关注

    Another way to access the attributes:

    echo $xml->entry[0]->link["href"];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器