ldoozer Posted September 20, 2010 Share Posted September 20, 2010 Can anyone tell me how to parse one of the child elements in the xml below.I have accesses title,link and description using the following php, but I need to access the image width for example which is a child element.Please help!echo '<ul>';foreach ( $items as $item ) {$href = $item['link'];$title = $item['title'];$img = $item['description'];echo "<li><a href=$href>" . $img . "</a></li>";}echo "</ul>"; <item> <title>DSC00071</title> <link> <description><p><a href="http://www.flickr.com/people/53764782@N08/">SteveDupree</a> posted a photo:</p> <p><a href=" title="DSC00071"><img src="http://farm5.static.flickr.com/4149/4964530050_c51dc91b8f_m.jpg" width="240" height="180" alt="DSC00071" /></a></p></description> <pubDate>Mon, 06 Sep 2010 10:05:19 -0700</pubDate> <dc:date.Taken>2007-08-08T11:01:16-08:00</dc:date.Taken> <author flickr:profile="http://www.flickr.com/people/53764782@N08/">[email protected] (SteveDupree)</author> <guid isPermaLink="false">tag:flickr.com,2004:/photo/4964530050</guid> <media:content url="http://farm5.static.flickr.com/4149/4964530050_54c8625a59_o.jpg" type="image/jpeg" height="1224" width="1632"/> <media:title>DSC00071</media:title> <media:thumbnail url="http://farm5.static.flickr.com/4149/4964530050_c51dc91b8f_s.jpg" height="75" width="75" /> <media:credit role="photographer">SteveDupree</media:credit> </item> Link to comment https://forums.phpfreaks.com/topic/213940-parsing-xml-child-elements/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.