当我执行var_dump($ xml)时,这是我的xml文件:
string(2763) "<?xml version="1.0" encoding="UTF-8"?> <response> <record> <field name="responseCode" value="000" /> <field name="responseDescription" value="Approved" /> </record> <record> <field name='Id' value='116696881908' /> <field name='customerId' value='4540931' /> <field name='accountNumber' value='5706161382' /> <field name='terminalId' value='2843448' /> <field name='channelType' value='1' /> <field name='internalReferenceId' value='146159604457' /> <field name='transactionType' value='19' /> <field name='transactionDate' value='2019/02/06' /> <field name='transactionTime' value='10:06:16' /> <field name='amount' value='4500' /> <field name='originalAmount' value='' /> <field name='pan' value='603799******4748' /> <field name='payerId' value='0' /> <field name='billId' value='' /> <field name='paymentId' value='' /> <field name='saleOrderId' value='' /> <field name='additionalData' value='10000C393839333336303836363538' /> <field name='settlementDate' value='2019/02/06' /> <field name='settlementTime' value='10:06:16' /> <field name='CHID' value='178269EADB297E8A5B6CECA1A490FD55' /> </record> <record> <field name='Id' value='116696881908' /> <field name='customerId' value='4540931' /> <field name='accountNumber' value='8128975422' /> <field name='terminalId' value='2843448' /> <field name='channelType' value='1' /> <field name='internalReferenceId' value='146159604457' /> <field name='transactionType' value='19' /> <field name='transactionDate' value='2019/02/06' /> <field name='transactionTime' value='10:06:16' /> <field name='amount' value='500' /> <field name='originalAmount' value='' /> <field name='pan' value='603799******4748' /> <field name='payerId' value='0' /> <field name='billId' value='' /> <field name='paymentId' value='' /> <field name='saleOrderId' value='' /> <field name='additionalData' value='10000C393839333336303836363538' /> <field name='settlementDate' value='2019/02/06' /> <field name='settlementTime' value='10:06:16' /> <field name='CHID' value='178269EADB297E8A5B6CECA1A490FD55' /> </record> </response>"
我想从中获取customerId。 我如何获得该价值?
$sxml = new SimpleXMLElement($xml);
var_dump(sxml)
$sxml
结果:
object(SimpleXMLElement)#469 (0) { }