我想將使用PHP的mysql表中的記錄保存到XML文件中。我正在成功檢索記錄並保存到數據庫中。 。 我想填充我的XML與我的客戶表中的所有記錄(CustomerAccountNumber,CustomerAccountName,AccountBalance,InvAddressLine1)使用PHP和MYSQL將多個屬性填充到XML中
這裏是我的代碼:
<?
$newAcct=$db_accnt;
$newAcctname=$db_accntname;
$newAcctbalance=$db_accntbalance;
$xmldoc=new DOMDocument();
$xmldoc->load('XML/customer.xml');
$newElement = $xmldoc->createElement('Row');
$newAttribute = $xmldoc->createAttribute('CustomerAccountNumber');
$newAttribute->value = $newAct;
$newElement->appendChild($newAttribute);
$root->appendChild($newElement);
?>
我的問題是:
如何生成customer.xml以及如何以有效的方式保存數千條記錄,以便基於中的數據庫此格式:
<?xml version="1.0" standalone="yes"?>
<Rows>
<Row CustomerAccountNumber="CU002" CustomerAccountName="Customer 1" AccountBalance="289.00" />
<Row CustomerAccountNumber="5U002" CustomerAccountName="Customer 2" AccountBalance="1899.00" />
<Row CustomerAccountNumber="CU004" CustomerAccountName="Customer 3" AccountBalance="289.00" />
<Row CustomerAccountNumber="5U032" CustomerAccountName="Customer 4" AccountBalance="1899.00" />
</Rows>
我沒有得到什麼線索,我需要做的產生多個屬性爲每個record.Kindly幫我