在iphone应用程序中解析youtube xml的问题

时间:2010-12-21 20:09:50

标签: iphone

问候语,          我正在我的应用程序中使用youtube。我得到如下的响应    / ---------------

enter code here



  <entry>
<id>http://gdata.youtube.com/feeds/api/videos/5iVl6iPODmM</id>
<published>2010-10-05T11:02:36.000Z</published>
<updated>2010-10-05T22:28:54.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='Entertainment' label='Entertainment'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Rusty'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='horse trainer'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Jacob Rhodes'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Secretariat'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Penny Chenery'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Jennifer Smart'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Gary Stevens'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='jockey'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='William Nack'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Otto Thorwarth'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Sean Michael Cunningham'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Willa Baker'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Dylan Baker'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='AJ Michalka'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Diane Lane'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Mark Ciardi'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Margo Martindale'/>
<title type='text'>Secretariat Red Carpet by Jennifer Smart</title>
<content type='text'>I've seen a lot of things on the red carpet, including a variety of animals, but this is the first time I've seen a real horse at a movie premiere! I enjoyed speaking with the actors and movie makers, and I learned a lot about Secretariat and the inspiring story about this Triple Crown winner beating the odds.</content>
<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=5iVl6iPODmM&amp;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/5iVl6iPODmM/responses'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/5iVl6iPODmM/related'/>
<link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=5iVl6iPODmM'/>
<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/JenSmartTV/uploads/5iVl6iPODmM'/>
<author>
     <name>JenSmartTV</name>
     <uri>http://gdata.youtube.com/feeds/api/users/jensmarttv</uri>
</author>
<gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/5iVl6iPODmM/comments' countHint='0'/></gd:comments>
<yt:location>Hollywood, CA</yt:location>
<media:group>
    <media:category label='Entertainment' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Entertainment</media:category>
    <media:content url='http://www.youtube.com/v/5iVl6iPODmM?f=user_uploads&amp;app=youtube_gdata' type='application/x-shockwave-flash'             medium='video' isDefault='true' expression='full' duration='547' yt:format='5'/>
     <media:content url='rtsp://v1.cache5.c.youtube.com/CigLENy73wIaHwljDs4j6mUl5hMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/      3gpp' medium='video' expression='full' duration='547' yt:format='1'/>
     <media:content url='rtsp://v6.cache2.c.youtube.com/CigLENy73wIaHwljDs4j6mUl5hMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/      3gpp' medium='video' expression='full' duration='547' yt:format='6'/>
     <media:description type='plain'>I've seen a lot of things on the red carpet, including a variety of animals, but this is the first time        I've seen a real horse at a movie premiere! I enjoyed speaking with the actors and movie makers, and I learned a lot about Secretariat and  the inspiring story about this Triple Crown winner beating the odds.</media:description>
     <media:keywords>Rusty, horse trainer, Jacob Rhodes,    Secretariat, Penny Chenery, Jennifer Smart, Gary Stevens, jockey, William Nack,         Otto Thorwarth, Sean Michael Cunningham, Willa Baker, Dylan     Baker, AJ Michalka, Diane Lane, Mark Ciardi, Margo Martindale</    media:keywords>
    <media:player url='http://www.youtube.com/watch?v=5iVl6iPODmM&amp;feature=youtube_gdata_player'/>
     <media:thumbnail url='http://i.ytimg.com/vi/5iVl6iPODmM/2.jpg' height='90' width='120' time='00:04:33.500'/>
     <media:thumbnail url='http://i.ytimg.com/vi/5iVl6iPODmM/1.jpg' height='90' width='120' time='00:02:16.750'/>
     <media:thumbnail url='http://i.ytimg.com/vi/5iVl6iPODmM/3.jpg' height='90' width='120' time='00:06:50.250'/>
     <media:thumbnail url='http://i.ytimg.com/vi/5iVl6iPODmM/0.jpg' height='240' width='320' time='00:04:33.500'/>
     <media:title type='plain'>Secretariat Red Carpet by Jennifer Smart</media:title>
     <yt:duration seconds='547'/>
</media:group>
<yt:recorded>2010-09-30</yt:recorded>
<yt:statistics favoriteCount='0' viewCount='60'/>
</entry>

// ------------- 现在我想获得媒体的价值:thumbnail,media:content url

我正在使用LIBXML2解析。 请帮忙! Thanx提前!!!我enter code here

1 个答案:

答案 0 :(得分:2)

如何使用Feed的JSON格式?您可以将?alt=json添加到URL以获取其JSON版本(例如,http://gdata.youtube.com/feeds/api/videos/5iVl6iPODmM?alt=json)。然后你可以使用JSON库(例如这个:http://stig.github.com/json-framework/)来解析它。

希望这有帮助!