Display images from xml file to php



Hello i am new here and new in (php and xml).Im trying to make an eshop wher i have xml files as "database".In fact one xml for each product...i display the data with php and all are going well exept the images....when i trying to display the images in the 'image td' it shows the path of the image and not the image... Have you any help for me...TY :)


php code



$files =glob('*.xml');
foreach($files as $file){
$xml=new SimpleXMLElement($file, 0, true);

$xpath = $xml->xpath("/wine/image");


?>
<tr>
<td><?php echo $xml->id ?></td>
<td><?php echo $xml->category ?></td>
<td><?php echo $xml->name ?></td>
<td><?php echo $xml->producer ?></td>
<td><?php echo $xml->price ?></td>
<td><?php echo $xpath[0]['src']; ?></td>



</tr>
<?php
} ?>


data.xml



<category>red</category>
<id>1</id>
<name>krasaki</name>
<producer>alkoolikos</producer>
<price>12.50</price>
<addcart>patato</addcart>
<image src="images/white_wine.jpg" width="50" height="50" />


and 'wine' is the root tag of the xml


No comments:

Post a Comment