Jump to content

Parsing XML child elements


ldoozer

Recommended Posts

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.