simplexml_load_string:如何在youtube的视频源中获取openSearch:itemsPerPage?

时间:2011-06-10 01:56:27

标签: php xml simplexml

使用simplexml_load_string如何以此格式从Feed中获取openSearch:itemsPerPage值:

http://code.google.com/apis/youtube/2.0/developers_guide_protocol_understanding_video_feeds.html

1 个答案:

答案 0 :(得分:0)

在SimpleXML中,您可以使用children('prefix',true)和attributes('prefix',true)函数来访问命名空间内容。

$xml = simplexml_load_string($string);
$itemsPerPage = (string)$xml->children('opensearch', true)->itemsPerPage;