我有这个XML文件我试图访问属性permission
的值在标签yt:accessControl
在php
echo (string)$xmlyt->entry->children('yt')->{'accessControl'}->attributes()->$actionAttr."------------";
但是我有错误
Node no longer exists
了解SimpleXML和XML的工作原理对完成这一任务非常有益。你可以通过尝试和错误来发现一些东西,最终得到这样的结果:
$sxml=simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/'.$videoID.'?v=2');
$yt = $sxml->children('http://gdata.youtube.com/schemas/2007');
print_r($yt->accessControl->attributes());
print_r($yt->accessControl[4]->attributes());
例如,这将为您提供第一个和第五个操作的权限,它们恰好是注释和嵌入ATM(可能应该遍历所有操作以识别您感兴趣的操作,而不是依赖于顺序)。
希望这有帮助,艾尔。