Jaxel
Well-known member
Okay... lets say I have the following XML feed:
If I parse this feed with SimpleXMLElement, it returns:
As you can see, I'm not retrieving any namespaced information... it doesn't parse media:group or any of it's children. How do I get access to this namespace? Basically I want to be able to do the following:
$title = $xml->media:group->media:title;
$duration = $xml->media:group->yt:duration->children('seconds');
Code:
<?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/kCVZv-cPC10</id>
<published>2009-04-02T22:58:20.000Z</published>
<updated>2010-08-27T06:19:27.000Z</updated>
<title type="text">Soul Edge/Blade: Introduction: Edge of Soul</title>
<author>
<name>Jaxelrod</name>
<uri>http://gdata.youtube.com/feeds/api/users/jaxelrod</uri>
</author>
<media:group>
<media:title type="plain">Soul Edge/Blade: Introduction: Edge of Soul</media:title>
<media:description type="plain">This introduction was done on the PSX...</media:description>
<media:keywords>Soul, Edge, Blade, Calibur, Soulcalibur, Team, Kogarasumaru, 8WayRun.com</media:keywords>
<media:thumbnail url="http://i.ytimg.com/vi/kCVZv-cPC10/2.jpg" height="90" width="120" time="00:01:06.500" />
<media:thumbnail url="http://i.ytimg.com/vi/kCVZv-cPC10/1.jpg" height="90" width="120" time="00:00:33.250" />
<media:thumbnail url="http://i.ytimg.com/vi/kCVZv-cPC10/3.jpg" height="90" width="120" time="00:01:39.750" />
<media:thumbnail url="http://i.ytimg.com/vi/kCVZv-cPC10/0.jpg" height="240" width="320" time="00:01:06.500" />
<yt:duration seconds="133" />
</media:group>
</entry>
If I parse this feed with SimpleXMLElement, it returns:
Code:
SimpleXMLElement Object
(
[id] => http://gdata.youtube.com/feeds/api/videos/kCVZv-cPC10
[published] => 2009-04-02T22:58:20.000Z
[updated] => 2010-08-27T06:19:27.000Z
[title] => Soul Edge/Blade: Introduction: Edge of Soul
)
As you can see, I'm not retrieving any namespaced information... it doesn't parse media:group or any of it's children. How do I get access to this namespace? Basically I want to be able to do the following:
$title = $xml->media:group->media:title;
$duration = $xml->media:group->yt:duration->children('seconds');