我有一个xml文件,但是当我尝试从中获取某些值时,它没有读取。下面是xml
<PaymentNotificationRequest>
<RouteId>HTTPSERVICE</RouteId>
<ServiceUrl>http://62.173.32.122:8085/</ServiceUrl>
<ServiceUsername/>
<ServicePassword/>
<FtpUrl>http://62.173.32.122:8085/</FtpUrl>
<FtpUsername/>
<FtpPassword/>
<Payments>
<Payment>
<ProductGroupCode>HTTPSERVICE</ProductGroupCode>
<PaymentLogId>12589</PaymentLogId>
<CustReference>806656919</CustReference>
<AlternateCustReference>abc@yahoo.com:</AlternateCustReference>
<Amount>500.00</Amount>
<PaymentStatus>0</PaymentStatus>
<PaymentMethod>Debit Card</PaymentMethod>
<PaymentReference>FBN|Web|3IWP0076|TST|120314160934|00000031</PaymentReference>
<TerminalId/>
<ChannelName>WEB</ChannelName>
<Location/>
<IsReversal>False</IsReversal>
<PaymentDate>03/12/2014 16:09:34</PaymentDate>
<SettlementDate>03/13/2014 00:00:01</SettlementDate>
<InstitutionId>TST</InstitutionId>
<InstitutionName>Test Scheme</InstitutionName>
<BranchName/>
<BankName>First Bank of Nigeria Plc</BankName>
<FeeName/>
<CustomerName>Nathan Henry</CustomerName>
<OtherCustomerInfo>|</OtherCustomerInfo>
<ReceiptNo>1407107249</ReceiptNo>
<CollectionsAccount>9393939393</CollectionsAccount>
<ThirdPartyCode/>
<PaymentItems>
<PaymentItem>
<ItemName>Fund Wallet</ItemName>
<ItemCode>1010</ItemCode>
<ItemAmount>500.00</ItemAmount>
<LeadBankCode>FBN</LeadBankCode>
<LeadBankCbnCode>011</LeadBankCbnCode>
<LeadBankName>First Bank of Nigeria Plc</LeadBankName>
</PaymentItem>
</PaymentItems>
<BankCode>FBN</BankCode>
<CustomerAddress/>
<CustomerPhoneNumber/>
<DepositorName/>
<DepositSlipNumber>FBN|WEB|QTELL|12-03-</DepositSlipNumber>
<PaymentCurrency>566</PaymentCurrency>
</Payment>
</Payments>
我希望能够在,,,甚至是。
中读取值但这就是我所拥有的
$xml = simplexml_load_file($filename);
foreach($xml as $value){
echo $value->Payment->Amount;
......
}
这些不会返回任何值。有人可以请帮忙吗?
答案 0 :(得分:3)
你忘记了&#34;付款&#34; tag:
$xml = simplexml_load_file($filename);
foreach($xml->Payments->Payment as $value){
echo $value->Amount;
......
}
您可以在PHP.net
找到其他示例