我正在开发一个使用codeigniter和youtube api的项目,我提出了一个视频请求,我收到了一些XML,我的问题是我不知道如何处理所述XML或更多到了如何解析它以便我可以获得我想要的值,我得到的XML,
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gd='http://schemas.google.com/g/2005'
xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<id>http://gdata.youtube.com/feeds/api/videos/x33JD3-hXHc</id>
<published>2010-11-29T21:28:22.000Z</published>
<updated>2011-03-14T12:01:51.000Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>
<category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Travel' label='Travel & Events'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Barney'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Harwood'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Interview'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='children's'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='bafta'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='awards'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='2010'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='red'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='carpet'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='host'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='tv'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='television'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='show'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='presenter'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='prank'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='patrol'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='the'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='sorcerer's'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='apprentice'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='bbc'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='cbbc'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='bear'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='behaving'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='badly'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='nev'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='smile'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='totally'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='doctor'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='who'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='basil's'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='swap'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='shop'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='basil'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='brush'/>
<title type='text'>Barney Harwood Interview</title>
<content type='text'>Barney Harwood Interview - We talk to children's TV presenter Barney Harwood on the red carept, ahead of his duties as host for the Children's BAFTA Awards 2010 in London. Presented by Michael Kurn Camera and Post by Russell Nelson</content>
<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=x33JD3-hXHc&feature=youtube_gdata'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/x33JD3-hXHc/responses'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.ratings' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/x33JD3-hXHc/ratings'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.complaints' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/x33JD3-hXHc/complaints'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/x33JD3-hXHc/related'/>
<link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=x33JD3-hXHc'/>
<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/x33JD3-hXHc'/>
<author>
<name>LeicesterSquareTV</name>
<uri>http://gdata.youtube.com/feeds/api/users/leicestersquaretv</uri>
</author>
<gd:comments>
<gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/x33JD3-hXHc/comments' countHint='5'/>
</gd:comments>
<yt:hd/>
<media:group>
<media:category label='Travel & Events' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Travel</media:category>
<media:content url='http://www.youtube.com/v/x33JD3-hXHc?version=3&f=videos&d=Ac2cvuTKQbM_TEZ_NAvfWNEO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='150' yt:format='5'/>
<media:content url='rtsp://v4.cache7.c.youtube.com/CkULENy73wIaPAl3XKF_D8l9xxMYDSANFEgGUgZ2aWRlb3NyIQHNnL7kykGzP0xGfzQL31jRDvPB7EI6RNWvHdRsUJxg5gw=/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='150' yt:format='1'/>
<media:content url='rtsp://v2.cache5.c.youtube.com/CkULENy73wIaPAl3XKF_D8l9xxMYESARFEgGUgZ2aWRlb3NyIQHNnL7kykGzP0xGfzQL31jRDvPB7EI6RNWvHdRsUJxg5gw=/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='150' yt:format='6'/>
<media:description type='plain'>Barney Harwood Interview -We talk to children's TV presenter Barney Harwood on the red carept, ahead of his duties as host for the Children's BAFTA Awards 2010 in London. Presented by Michael Kurn
Camera and Post by Russell Nelson
</media:description>
<media:keywords>Barney, Harwood, Interview, children's, bafta, awards, 2010, red, carpet, host, tv, television, show, presenter, prank, patrol, the, sorcerer's, apprentice, bbc, cbbc, bear, behaving, badly, nev, smile, totally, doctor, who, basil's, swap, shop, basil, brush
</media:keywords>
<media:player url='http://www.youtube.com/watch?v=x33JD3-hXHc&feature=youtube_gdata_player'/>
<media:thumbnail url='http://i.ytimg.com/vi/x33JD3-hXHc/0.jpg' height='360' width='480' time='00:01:15'/>
<media:thumbnail url='http://i.ytimg.com/vi/x33JD3-hXHc/1.jpg' height='90' width='120' time='00:00:37.500'/>
<media:thumbnail url='http://i.ytimg.com/vi/x33JD3-hXHc/2.jpg' height='90' width='120' time='00:01:15'/>
<media:thumbnail url='http://i.ytimg.com/vi/x33JD3-hXHc/3.jpg' height='90' width='120' time='00:01:52.500'/>
<media:title type='plain'>Barney Harwood Interview</media:title><yt:duration seconds='150'/>
</media:group>
<gd:rating average='5.0' max='5' min='1' numRaters='1' rel='http://schemas.google.com/g/2005#overall'/>
<yt:statistics favoriteCount='0' viewCount='1141'/>
</entry>
具体如何获取缩略图?
答案 0 :(得分:1)
答案 1 :(得分:0)
我不确定您是否使用我开发的库。 Here is the link。如果您有,则可以将“alt”参数传递到库调用中,以便指定数据的返回方式。如果将其设置为JSON,则可以使用PHP内置的json_decode函数。
即使您没有使用我的库,您仍然可以使用alt参数,只需在GET uri上指定它。