I want to extract data from an xml file and insert into variables. My code is working but is only showing the first records rather than all the records. What am I doing wrong?
<merchantProductFeed>
<merchant id="8" name="Drinkstuff.com">
<prod id="57801251" in_stock="yes">
<pId>1264-553</pId>
<text>
<name>Lord of the Rings Pinball</name>
<desc>The greatest adventure of all time is now Stern Pinball&#8217;s epic pinball machine for all ages. THE LORD OF THE RINGS&#8482; pinball machine features exciting elements from New Line Cinema&#8217;s box office hits, THE FELLOWSHIP OF THE RING&#8482; and THE TWO TOWERS, as well as the most anticipated installment yet, THE RETURN OF THE KING&#8482;</desc>
</text>
<uri>
<awTrack>http://www.awin1.com/pclick.php?p=57801251&a=XXXXX&m=8</awTrack>
<awThumb>http://images.productserve.com/thumb/8/57801251.jpg</awThumb>
<awImage>http://images.productserve.com/preview/8/57801251.jpg</awImage>
<mLink>http://www.drinkstuff.com/products/affiliate.asp?affID=987654321&prodID=553</mLink><mImage>http://www.drinkstuff.com/productimg/14184.jpg</mImage>
</uri>
<price><buynow>3993.18</buynow>
<delivery>0.00</delivery>
</price>
<cat>
<awCatId>577</awCatId>
<awCat>Retro Games</awCat>
<mCat>Arcade Machines</mCat>
</cat>
</prod>
</merchant>
</merchantProductFeed>
This is just one record from a particular merchant.
Ok, just tried that adjustment to my code but it still only displays the first record for each merchant and not all products from each merchant. Any ideas would be greatly appreciated.
Thanks for the rapid response. Tried your code it works great. Had to make a minor adjustment to display the product name. Many thanks for the help. Have to say that this forum has helped me out no end and it’s great to know that help is at hand. I have learnt so much.
I have another question however, if I want to insert the values returned into my database can I use the same structure to assign variables rather than echoing out?
Because I’m using foreach loops to get the values, how can I construct the INSERT query? If I make the query outside the loop won’t the variable be populated with the last record? Or will I have to construct the query in parts? No need to reply sorted it myself. Thanks anyway. Wahey!!! Over 100 posts!