Zend_Feed Requests and Separates Colons

I created a function that uses an RSS feed from Flickr using Zend_Feed. Unfortunately, I am struggling to extract some keys!

I can get <title> etc. echoing

$entry->title();

      

But how can I repeat something like <media: thumbnail>?

I'm sure there is a perfectly simple way to do this, but I can't figure it out for my life!

Here is a sample entry

<entry>
<id>http://gdata.youtube.com/feeds/api/videos/T-Pq6QSeH7A</id>
<published>2009-09-16T11:51:20.000Z</published>
<updated>2009-09-18T02:37:35.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='Games' label='Gaming'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='torchlight'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='vanquisher'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='mmo'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='mmorpg'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='massively'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='multiplayer'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='online'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='game'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='mmohub'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='hub'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='forums'/>
<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='reviews'/>
<title type='text'>Torchlight - Vanquisher Gameplay</title>
<content type='text'>I'm so excited to reveal the latest trailer for Torchlight, featuring the third class, the Vanquisher!</content>
<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=T-Pq6QSeH7A&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/T-Pq6QSeH7A/responses'/>
<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/T-Pq6QSeH7A/related'/>
<link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=T-Pq6QSeH7A'/>
<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/mmolifetv/uploads/T-Pq6QSeH7A'/>
<author>
  <name>mmolifetv</name>
  <uri>http://gdata.youtube.com/feeds/api/users/mmolifetv</uri>
</author>
<gd:comments>
  <gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/T-Pq6QSeH7A/comments' countHint='0'/>
</gd:comments>
<media:group>
  <media:category label='Gaming' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Games</media:category>
  <media:content url='http://www.youtube.com/v/T-Pq6QSeH7A?f=user_uploads&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='97' yt:format='5'/>
  <media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwmwH54E6erjTxMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='97' yt:format='1'/>
  <media:content url='rtsp://rtsp2.youtube.com/CigLENy73wIaHwmwH54E6erjTxMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='97' yt:format='6'/>
  <media:description type='plain'>I'm so excited to reveal the latest trailer for Torchlight, featuring the third class, the Vanquisher!</media:description>
  <media:keywords>torchlight, vanquisher, mmo, mmorpg, massively, multiplayer, online, game, mmohub, hub, forums, reviews</media:keywords>
  <media:player url='http://www.youtube.com/watch?v=T-Pq6QSeH7A&amp;feature=youtube_gdata'/>
  <media:thumbnail url='http://i.ytimg.com/vi/T-Pq6QSeH7A/2.jpg' height='90' width='120' time='00:00:48.500'/>
  <media:thumbnail url='http://i.ytimg.com/vi/T-Pq6QSeH7A/1.jpg' height='90' width='120' time='00:00:24.250'/>
  <media:thumbnail url='http://i.ytimg.com/vi/T-Pq6QSeH7A/3.jpg' height='90' width='120' time='00:01:12.750'/>
  <media:thumbnail url='http://i.ytimg.com/vi/T-Pq6QSeH7A/0.jpg' height='240' width='320' time='00:00:48.500'/>
  <media:title type='plain'>Torchlight - Vanquisher Gameplay</media:title>
  <yt:duration seconds='97'/>
</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='24'/>

      

I would like to extract the first sketch of a sketch from a recording.

+2


source to share


3 answers


a colon in a key means the namespace is being used. One of the media that will be defined elsewhere in XML as pointing to the yahoo domain is quite common in RSS. Zend_Feed picks up the namespace sometimes and have you tried $ entry-> thumbnail ()?

Alternatively, I remember that there is a method getDom

that will return a DOMDocument to you, on which you can use all the built-in NS mapping methods (for example getElementsByTagNameNS

).



Or take a look at the new Zend_Feed_Reader stuff - it might have media namespace support already, or writing your own adapter is pretty straightforward - there is an example in the docs for plugging Amazon's ISAN into some of your feeds that you'd be able to copy.

+2


source


$ entry-> media () → thumbnails ()

can work or



$entry->{'media:thumbnail'}

      

But I'm not 100% sure.

+1


source


I solved it using Zend Gdata YouTube, but I'm still wondering how it can be done like this, although I may use Zend_Feed in the future for similar things!

0


source







All Articles