MySQL çıktı SimpleXML

0 Cevap php

Benim e-ticaret sitesinden alınan aşağıdaki XML dosyasını okumak ve MySQL kayıtları eklemek istiyorum. Ben SimpleXML kullanarak denedim ama işe yarıyor görünmüyor.

<ACCOUNT NumCrds="1">
<ACCNO>HAA_00</ACCNO>
<CURRCODE>CAD</CURRCODE>
<ACCTYPE>00</ACCTYPE>
<FINAMT>0.00</FINAMT>
<BLKAMT>0.00</BLKAMT>
<AMTAVL>0.00</AMTAVL>
<CARD>
<PANNU>1234567890208108</PANNU>
<PRIMARY>Y</PRIMARY>
<CRDPRODUCT>PCAD</CRDPRODUCT>
<PROGRAMID>PTYCSH</PROGRAMID>
<CUSTCODE>00000406</CUSTCODE>
<STATCODE>02</STATCODE>
<EXDATE>2013-03-31</EXDATE>
<CRDACCNO>HAA_00</CRDACCNO>
<CRDCURRCODE>CAD</CRDCURRCODE>
</CARD>
</ACCOUNT>

<ACCOUNT NumCrds="1">
<ACCNO>XYZCESFULL9900</ACCNO>
<CURRCODE>CAD</CURRCODE>
<ACCTYPE>00</ACCTYPE>
<FINAMT>0.00</FINAMT>
<BLKAMT>0.00</BLKAMT>
<AMTAVL>0.00</AMTAVL>
<CARD>
<PANNU>0987654321756990</PANNU>
<PRIMARY>Y</PRIMARY>
<CRDPRODUCT>PCAD</CRDPRODUCT>
<PROGRAMID>PTYCSH</PROGRAMID>
<CUSTCODE>00000520</CUSTCODE>
<STATCODE>00</STATCODE>
<EXDATE>2013-04-30</EXDATE>
<CRDACCNO>XYZCESFULL9900</CRDACCNO>
<CRDCURRCODE>CAD</CRDCURRCODE>
</CARD>
</ACCOUNT>

Ben beklendiği gibi çalıştığını aşağıdaki kodu yazdım.

<?php
$sxe = simplexml_load_file("balexp.xml");
foreach($sxe->ACCOUNT as $item) {
$mysql="insert into test.mytable values ('".$item->ACCNO."','".$item->CURRCODE."')";
echo $mysql;
}
?>

But I have 1 question to ask. 1) There are times when I need to process 2 cards in the same ACCOUNT clause. How do I handle such situations?

0 Cevap