July 20, 201016 yr Hi there, I have an XML file with the following structure, <item> <name></name> <description></description> <Images> <img src="" alt="" width="" height="" /> <img src="" alt="" width="" height="" /> <img src="" alt="" width="" height="" /> <img src="" alt="" width="" height="" /> </Images> </item> their are about 100 items but when i loop through each item and echo them onto the screen I only one to display one of the images that is listed.. Can anyone help me with the code to display just one? I have tried: $item->Images $item->Images->img[1]->attributes()->src but this does not seem to display anything and I know that using children() will just show a count of the children.. Im pulling my hair out and it seems like such a small problem Thanks, Chris
July 20, 201016 yr Author its on the same server This is the code that I am using so far.. $inventorylink = 'inventory.xml'; $feed = simplexml_load_file($inventorylink); // Display Results foreach ($feed->item as $item) { echo "<tr>"; echo"<td><strong><a href=\"\" title=\"\">$item->title</a></strong></td>"; echo "<td rowspan=\"2\" style=\"vertical-align:top; padding-bottom:15px;\">$item->Images->img[1]->attributes()->src</td>"; echo "</tr>"; echo "<tr>"; echo "<td><strong>Features:</strong> $item->description <br /><a href=\"\" title=\"More Details On The $item->title\">More Details</></td>"; echo "</tr>"; } I hope this makes sense Thanks, Chris
July 20, 201016 yr You've done it the right way, however you need to either remove the string out of the double quotes or surround it with { } changing $item->Images->img[1]->attributes()->src to {$item->Images->img[1]->attributes()->src} Also img[1] is the second images value, as the array is 0 based
July 20, 201016 yr Author Hey Jay, How would I go about echoing all the images out on the page for each item rather than just one? some items have multiple images and some have none :S Thanks, Chris
Create an account or sign in to comment