11-03-2008, 08:21 PM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
SimpleXML isn't quite so simple when it comes to namespaced items. (Using the full url for the media namespace.)
PHP Code:
// Grab media: nodes for this item $media = $xml->channel->item[$i]->children('http://search.yahoo.com/mrss/');
// Grab media:thumbnail node $thumbnail = $media->thumbnail->attributes();
// Grab media:thumbnail url attribute $img = (string) $thumbnail->url;
Alternatively, thanks to chaining we can tidy things up a bit:
PHP Code:
$img = (string) $item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url;
I hope that provides a starting point.
P.S. As of PHP 5.2.0 you can alternatively use the namespace label rather than the uri. E.g. $item->children('media', TRUE)->thumbnail…
Last edited by Salathe : 05-29-2009 at 09:07 AM.
|
|
|
|