huyhoangytn
New Member
I have about 60000 xml files that i have to insert into a MySQL database. so i thought about making a simple php script that would be executed for once to load data from this xml files and insert it into my db on a localhost.Before inserting it into my DB i tried to show them on the data on the page but it shows nothing, and its type is NULL. here is the code : \[code\]<?php$dir = new DirectoryIterator('organismes');foreach ($dir as $fileinfo) { if (!$fileinfo -> isDot()) { $XMLFILE = $fileinfo -> getFilename(); echo $XMLFILE . "<br>\n"; /*the filename shows correctly, so the DirectoryIterator is working*/ $pathtofile = "http://localhost/www/organismes/$XMLFILE"; /*the link to the xml file made with a variable*/ echo $pathtofile . "<br>\n"; /* the link shown is correct */ $xml = simplexml_load_file($pathtofile); echo gettype($xml) . "<br>\n"; if ($xml == FALSE) { echo "failed to load xml"; /* this message never shows so the xml file loads correctly */ } else { $Org = $xml->Organisme->Nom; //this variable $Org gets a NULL Value echo $Org . "<br>" ; echo gettype($Org); } }}?>\[/code\]when i used a print_r($xml), it shows some data so the file loads correctly.and here is an example of the xml file that i have :\[code\]<Organisme id="adil-01053-01" codeInsee="01053" dateMiseAJour="2013-02-27" pivotLocal="adil"><Nom>Agence</Nom> <EditeurSource>A2 A3</EditeurSource><Adresse type="g