lambertmagpie
New Member
I have an XML file \[code\]<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header /> <s:Body> <GetAllItemCategoryResponse xmlns="http://tempuri.org/"> <GetAllItemCategoryResult xmlns:a="http://schemas.datacontract.org/2004/07/HQService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:ItemsCategory> <a:Code>prov</a:Code> <aescription>Te Fresketa</aescription> <a:LastModifiedDate>0001-01-01T00:00:00</a:LastModifiedDate> <a:active>true</a:active> </a:ItemsCategory> </GetAllItemCategoryResult> </GetAllItemCategoryResponse> </s:Body> </s:Envelope>\[/code\]I need to read this file and store the records to the database.Till now i have managed to upload and read the records however i cannot store them in my database. I have looked at this example which has similar XML format with my case but it does not work PHP - converting XML to array in PHP - parsing a soap xml in php and storing it in databaseI am using CodeIgniter(below is my code)\[code\]function set_xml(){ if ($this->input->post('submit')) { //uploading the file to the server if (!empty($_FILES['userfile']['name'])){ $this->upload->do_upload($_FILES['userfile']['name']); } } $xml = realpath(APPPATH . '../public/').'/'.$_FILES['userfile']['name']; $fh = fopen($xml,'r'); $theData = http://stackoverflow.com/questions/13840745/fread($fh,filesize($xml)); fclose($fh); $element = new simpleXMLElement($theData); $centerElement = $element->Body->GetAllItemCategoryResponse->GetAllItemCategoryResult->ItemsCategory; $center = array( $centerElement->Code ); var_dump($centerElement);}\[/code\]Any help please?