codeigniter と php を使用して、xml ファイルから mysql データベースにデータを保存しようとしています。しかし、特殊な xml 文字をエスケープして、データを xml ファイルからテーブル cache_table に保存する方法が見つかりませんでした。
Code:
$xml_source = str_replace(array("&", "&"), array("&", "&"),file_get_contents('XML/customer.xml'));
$xml = simplexml_load_string($xml_source);
foreach($xml as $row )
{
$attr = $row->attributes();
$results[] = array('CustomerAccountNumber' => $this->db->escape_str($attr->CustomerAccountNumber),'Desciption' => $this->db->escape_str($attr->Desciption) ):
$this->db->insert_batch('cache_cust',$results);
しかし、私はこのエラーが発生しています:
エラー:
simplexml_load_string(): エンティティ: 37 行目: パーサー エラー: エスケープされていない '<' は属性値では許可されていません。
顧客.xml
<?xml version="1.0" standalone="yes"?>
<Rows>
<Row CustomerAccountNumber="12" Name="Arj" Desciption="PJ psm" />
<Row CustomerAccountNumber="1" Name="Aj" Desciption="*/Artic" />
<Row CustomerAccountNumber="2" Name="smla" Desciption="& light" />
<Row CustomerAccountNumber="3" Name="alik" Desciption="*/Artic" />
<Row CustomerAccountNumber="4" Name="wqla" Desciption="" />
<Row CustomerAccountNumber="5" Name="walij" Desciption="16-17" />
<Row CustomerAccountNumber="6" Name="li" Desciption="sales@llil.com" />
</Rows>
コードがすべてのレコードを xml ファイルからデータベースに保存するように、このエラーを回避し、特殊な xml 文字を回避するにはどうすればよいですか?