【发布时间】:2011-04-30 10:23:53
【问题描述】:
我正在使用 SimpleXML 解析 YouTube 搜索提要。我想在搜索一个词后在提要中获得第一个结果。现在我的代码如下所示:
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);
上面代码的输出是:
SimpleXMLElement Object
(
[@attributes] => Array
(
[rel] => alternate
[type] => text/html
[href] => http://www.youtube.com/watch?v=TveGAmLdn8k&feature=youtube_gdata
)
)
如何获得“href”的值?
谢谢。
【问题讨论】: