I am getting external xml files (through file exchange) and I am able to read and store in the database (php/mysql). The xml files come zipped under different names and sometimes several files come together zipped in a folder
When the folder has only 1 xml file,I am able to successfully unzip and read the content using
$path = '/xmlFile';
//the xmlFile names are in this format : xmFile-00001235.xml,
//xmlFile-000012390.xml, etc. only first portions are consistent
foreach (glob($path.'/xmlFile-*.xml') as $filename)
{
$xml=file_get_contents($filename);
}
//store in database and unlink the xml file
This only works if the folder has one xml file, because I am un-linking the xml file after storage, it un-links all the files but only stores one
What would be the best approach; I am thinking of checking if the folder has more than 1 xml and combine the xml files? maybe a sample solution will really help,
The sample xml is as follows
xml1.xml
<sales>
<row id="000001" saleid="267158" amountSold="2000" />
<row id="000001" saleid="267159" amountSold="80.000" />
</sales>
xml2.xml
<sales>
<row id="000001" saleid="267160" amountSold="4000" />
<row id="000001" saleid="267161" amountSold="580" />
</sales>