simple_xml - Assigning variable to tag - only returning first

haultussy

New Member
I'm trying to create an XML importer to load products from a POS system to an online store.I'm wanting to go about this by getting the XML export from the POS system, process it and put the values directly into the multiple tables of the database.The beginning of the code looks like this however I've already ran into a stumbling block.\[code\]<?php $xml = simplexml_load_file('product.xml');$ProductName = $xml->Product->Name;$ProductDescription = $xml->Product->Description;$IsNew = str_replace("false", "0", $xml->Product->IsNew) // Sets False to 0 instead of falseecho $ProductName . "<br />";echo $ProductDescription . "<br />";echo $IsNew;?>\[/code\]So far I'm just trying to get the data from the XML Tags, put them in variables, and echo them so I see that I'm getting the right results.This is only returning the details of the first product of the XML file (from over a thousand). I was expecting it to get the Name+Description+IsNew for every product. I'm assuming it needs to be in a while statement, but I can't figure out how to apply this with simple_xmlThe XML structure looks like this.\[code\]<PRODUCTS> <PRODUCT> <UPDATETYPE> <STYLECODE> <NAME> <DESCRIPTION> ...etc... <ITEMS> <ITEM> <CODE> <BARCODE> <SIZE> <PRICE> ...etc... </ITEM> <ITEM> ...etc... </ITEM> </ITEMS> </PRODUCT> <PRODUCT> ...etc... </PRODUCT></PRODUCTS>\[/code\]
 
Back
Top