【发布时间】:2013-03-09 00:23:02
【问题描述】:
我需要从这样的提要中获取非常具体的值:
http://gdata.youtube.com/feeds/api/videos/iIp7OnHXBlo
我必须从这些格式奇怪的 XML 提要中读取的一些节点是:
<title type="text">Uploading YouTube Videos with the PHP Client Library</title>
<media:content url="http://www.youtube.com/v/iIp7OnHXBlo?version=3&f=videos&app=youtube_gdata" type="application/x-shockwave-flash" medium="video" isDefault="true" expression="full" duration="466" yt:format="5"/>
<media:content url="rtsp://v3.cache7.c.youtube.com/CiILENy73wIaGQlaBtdxOnuKiBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="466" yt:format="1"/>
<media:description type="plain">Jochen Hartmann demonstrates the basics of how to use the PHP Client Library with the YouTube Data API. [...]</media:description>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/0.jpg" height="360" width="480" time="00:03:53"/>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/1.jpg" height="90" width="120" time="00:01:56.500"/>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/2.jpg" height="90" width="120" time="00:03:53"/>
<media:thumbnail url="http://i.ytimg.com/vi/iIp7OnHXBlo/3.jpg" height="90" width="120" time="00:05:49.500"/>
<yt:duration seconds="466"/>
当然,为 GData 使用 Zend Framework API 绝对不可能(1225 个文件和 49 MB 只是为了解析 XML 文件?是的,当然。 ..我的主。
我需要使用 lastRSS 解析器或任何 PHP 中的内置 XML 函数,就像任何头脑正常的人一样。提前感谢您的任何提示。
【问题讨论】:
-
你需要这个服务器端还是客户端?
-
什么是奇怪的格式?您想知道该文档中使用的 XML 名称空间吗?我一直认为,如果使用图像、音频或视频等媒体,它们对于 atom 提要非常常见。
-
可能重复通过 SimpleXML 访问 XML 命名空间中的元素(关于该主题的问答,甚至应该使用 Youtube 特定的 XML,例如 How can i get to xml attribute of <yt:accesscontrol>? 或 Get XML Attribute with SimpleXML)。
标签: php xml parsing youtube xml-namespaces