0
我有一個XML文件XML SOAP保存到MySQL數據庫
<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>
<a:Description>Te Fresketa</a:Description>
<a:LastModifiedDate>0001-01-01T00:00:00</a:LastModifiedDate>
<a:active>true</a:active>
</a:ItemsCategory>
</GetAllItemCategoryResult>
</GetAllItemCategoryResponse>
</s:Body>
</s:Envelope>
我需要閱讀該文件和記錄存儲到數據庫中。 直到現在我設法上傳和閱讀記錄,但是我不能將它們存儲在我的數據庫中。我已經看過這個例子也有類似的XML格式與我的情況,但它不工作我使用笨PHP - converting XML to array in PHP - parsing a soap xml in php and storing it in database
(下面是我的代碼)
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 = fread($fh,filesize($xml));
fclose($fh);
$element = new simpleXMLElement($theData);
$centerElement = $element->Body->GetAllItemCategoryResponse->GetAllItemCategoryResult->ItemsCategory;
$center = array(
$centerElement->Code
);
var_dump($centerElement);
}
任何幫助嗎?
謝謝你的開發工作! –
哇 - 你認真的搖出來找出它併發布 – cartalot