A-AA+then

อยากเก็บ xml file ลง Database my-SQL (ใช้ PHP) ท่านเทพ ช่วยด้วยค

2,420

<?xml version="1.0" encoding="UTF-8" ?>

- <FnoDailyTrdSumRpt:FnoDailyTrdSumRpt xmlns:FnoDailyTrdSumRpt="http://www.excel.com.hk/settlement/FnoDailyTrdSumRpt/">
- <FnoDailyTrdSumRpt:Header>
  <FnoDailyTrdSumRpt:ID>R2603</FnoDailyTrdSumRpt:ID>
  <FnoDailyTrdSumRpt:Title>F & Summary Report As At 29/01/2009</FnoDailyTrdSumRpt:Title>
  <FnoDailyTrdSumRpt:Company>TESTCOMPANY .</FnoDailyTrdSumRpt:Company>
  <FnoDailyTrdSumRpt:PrintTime>20090129 20:22</FnoDailyTrdSumRpt:PrintTime>
  <FnoDailyTrdSumRpt:BusDate>30/01/2009</FnoDailyTrdSumRpt:BusDate>
  </FnoDailyTrdSumRpt:Header>
- <FnoDailyTrdSumRpt:ClientTradeData>
- <FnoDailyTrdSumRpt:ClientTradeRecord>
  <FnoDailyTrdSumRpt:TDNo>F090002510</FnoDailyTrdSumRpt:TDNo>
  <FnoDailyTrdSumRpt:ExtRefNo>8481677200901291635091</FnoDailyTrdSumRpt:ExtRefNo>
  <FnoDailyTrdSumRpt:BuyQty>2</FnoDailyTrdSumRpt:BuyQty>
  <FnoDailyTrdSumRpt:SellQty>0</FnoDailyTrdSumRpt:SellQty>
  <FnoDailyTrdSumRpt:Price>291.9</FnoDailyTrdSumRpt:Price>
  <FnoDailyTrdSumRpt:ClosedQty>2</FnoDailyTrdSumRpt:ClosedQty>
  <FnoDailyTrdSumRpt:ContractCode>S50H09</FnoDailyTrdSumRpt:ContractCode>
  <FnoDailyTrdSumRpt:ContractName>SET5003/2009</FnoDailyTrdSumRpt:ContractName>
  <FnoDailyTrdSumRpt:CaccCode>888-031252-0-3</FnoDailyTrdSumRpt:CaccCode>
  <FnoDailyTrdSumRpt:CaccName>ปราโมทย์ ทำดี</FnoDailyTrdSumRpt:CaccName>
  <FnoDailyTrdSumRpt:ProductNatureCode>F</FnoDailyTrdSumRpt:ProductNatureCode>
  <FnoDailyTrdSumRpt:ProductNatureDesc>SET50</FnoDailyTrdSumRpt:ProductNatureDesc>
  <FnoDailyTrdSumRpt:FnoTypeCode>S50</FnoDailyTrdSumRpt:FnoTypeCode>
  <FnoDailyTrdSumRpt:ExBoard>TXI</FnoDailyTrdSumRpt:ExBoard>
  <FnoDailyTrdSumRpt:TradeCategory>F</FnoDailyTrdSumRpt:TradeCategory>
  </FnoDailyTrdSumRpt:ClientTradeRecord>
- <FnoDailyTrdSumRpt:ClientTradeRecord>
  <FnoDailyTrdSumRpt:TDNo>F090002511</FnoDailyTrdSumRpt:TDNo>
  <FnoDailyTrdSumRpt:ExtRefNo>8481692200901291635111</FnoDailyTrdSumRpt:ExtRefNo>
  <FnoDailyTrdSumRpt:BuyQty>48</FnoDailyTrdSumRpt:BuyQty>
  <FnoDailyTrdSumRpt:SellQty>0</FnoDailyTrdSumRpt:SellQty>
  <FnoDailyTrdSumRpt:Price>292</FnoDailyTrdSumRpt:Price>
  <FnoDailyTrdSumRpt:ClosedQty>48</FnoDailyTrdSumRpt:ClosedQty>
  <FnoDailyTrdSumRpt:ContractCode>S50H09</FnoDailyTrdSumRpt:ContractCode>
  <FnoDailyTrdSumRpt:ContractName>SET5003/2009</FnoDailyTrdSumRpt:ContractName>
  <FnoDailyTrdSumRpt:CaccCode>888-031252-0-3</FnoDailyTrdSumRpt:CaccCode>
  <FnoDailyTrdSumRpt:CaccName>ปราโมทย์ ทำดี</FnoDailyTrdSumRpt:CaccName>
  <FnoDailyTrdSumRpt:ProductNatureCode>F</FnoDailyTrdSumRpt:ProductNatureCode>
  <FnoDailyTrdSumRpt:ProductNatureDesc>SET50</FnoDailyTrdSumRpt:ProductNatureDesc>
  <FnoDailyTrdSumRpt:FnoTypeCode>S50</FnoDailyTrdSumRpt:FnoTypeCode>
  <FnoDailyTrdSumRpt:ExBoard>TXI</FnoDailyTrdSumRpt:ExBoard>
  <FnoDailyTrdSumRpt:TradeCategory>F</FnoDailyTrdSumRpt:TradeCategory>
  </FnoDailyTrdSumRpt:ClientTradeRecord>
  <FnoDailyTrdSumRpt:ClientTradeRecord />
  </FnoDailyTrdSumRpt:ClientTradeData>
  <FnoDailyTrdSumRpt:Footer>*** End Of Report ***</FnoDailyTrdSumRpt:Footer>
  </FnoDailyTrdSumRpt:FnoDailyTrdSumRpt>

2 ความคิดเห็น

555+++

ก็เก็บไปดิคำถามไม่เห็นมันจะมีอะไรเลย XML มันก็แค่ข้อมูล Text ธรรมดา
1

อยากเก็บ แบบ นี้ ครับ

field1                       field2                                                  field3     field4     fileld5  filed6    filed7         filed8                    F090002510      8481677200901291635091          2           0           291.9  2          S50H09   SET5003/2009 
F090002511      8481692200901291635111          48         0          292      48        S50H09   SET5003/2009

อยากได้ตัวอย่างหรือ code การตัด field ที่จะจัดเก็บแต่ละ filed ลง databaes อะครับ

ลองเขียนแบบ code ด้านล่าง มันอ่าน field ไม่ได้ครับ

<!DOCTYPE html PUBLIC "//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<table width="942" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="13" height="27">&nbsp;</td>
    <td width="917">&nbsp;</td>
    <td width="12">&nbsp;</td>
  </tr>
  <tr>
    <td height="27">&nbsp;</td>
    <td valign="top"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="182">&nbsp;</td>
    <td>
      <p>
        <?php
$xml = simplexml_load_file("R2603.xml") or die("feed not loading");

foreach($xml as $FnoDailyTrdSumRpt:ClientTradeData){

echo "<td><a href=" .$FnoDailyTrdSumRpt:ClientTradeData->HLINK .">".$FnoDailyTrdSumRpt:ClientTradeData->TDNo."</a></td>";
echo "<td>" . $FnoDailyTrdSumRpt:ClientTradeData->ExtRefNo . "</td>";
echo "<td>" . $FnoDailyTrdSumRpt:ClientTradeData->BuyQty . "</td>";
echo "<td>" . $FnoDailyTrdSumRpt:ClientTradeData->SellQty . "</td>";
echo "<td>" . $FnoDailyTrdSumRpt:ClientTradeData->Price . "</td>";
echo "<td>" . $FnoDailyTrdSumRpt:ClientTradeData->ClosedQty . "</td>";
echo "<td>" .$FnoDailyTrdSumRpt:ClientTradeData->ContractCode . "</td>";
echo "<td><a href=" .$FnoDailyTrdSumRpt:ClientTradeData->HLINK. "><img src=" .$FnoDailyTrdSumRpt:ClientTradeData->TradeCategory ."/></td>";

}

?>
 </body>
</html>

2
^