Php 对非对象调用成员函数attributes()

Php 对非对象调用成员函数attributes(),php,attributes,simplexml,Php,Attributes,Simplexml,我正在尝试使用simplexml从Youtube视频URL读取内容xml标记,但是当我添加attributes函数时,它给出了错误: 对非对象调用成员函数attributes() Php代码: $xml = simplexml_load_file("http://gdata.youtube.com/feeds/api/videos/FS5uQpBp8XI/related?v=2"); $content = $xml->children("http://search.yahoo.com/m

我正在尝试使用simplexml从Youtube视频URL读取内容xml标记,但是当我添加attributes函数时,它给出了错误:

对非对象调用成员函数attributes()

Php代码:

$xml = simplexml_load_file("http://gdata.youtube.com/feeds/api/videos/FS5uQpBp8XI/related?v=2");

$content = $xml->children("http://search.yahoo.com/mrss/")->group->content[0]->attributes();

$src = $content->url;

echo $src;

您正在调用不属于简单xml对象的方法。试着使用打印工具,这样你就可以找到你想要打印出的属性了。除了我的答案,你介意从该URL中包含一个示例XML吗?修改了我的回答,但你可能想告诉我们,你在这个巨大的XML中到底要找什么。一个独生子女?我想得到每个媒体的URL属性:内容节点位于“条目”下的相关链接?