php - Parse feed media group with array of children -
i have xml feed:
<item> <title>title</title> <media:group> <media:content url="http://example.it/image.jpg" type="image/jpeg"> <media:thumbail url="http://example.it/image.jpg" type="image/png"/> <media:credit>credit</media:credit> </media:content> <media:content url="http://example.it/image2.jpg" type="image/jpeg"> <media:thumbail url="http://example.it/image2.jpg" type="image/png"/> <media:credit>credit2</media:credit> </media:content> </media:group> </item>
this php code read it:
$rss = new simplexmlelement($url); foreach ($rss->channel->item $item) { $title = $item->title; }
no problem reading "title" item, how can read "url", "thumbnail", "credit" each media:content?
-------solved-------
$rss = new simplexmlelement($url); foreach ($rss->channel->item $item) { $title = $item->title; $gallerie = $item->children('http://search.yahoo.com/mrss/')->group->content; foreach($gallerie $g) { echo $g->attributes()['url'] ."<br/>"; } }
Comments
Post a Comment