0

I have an xml file, but it's not reading when i try to get certain values from it. Below is the 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>[email protected]:</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>

I want to be able to read values in , , , and even .

But this is what i have

$xml = simplexml_load_file($filename);
foreach($xml as $value){
    echo $value->Payment->Amount;
    ......
} 

These do not return any value. Can someone please, help?

2
  • Please read through your question yourself. Your formatting is not working, you have an issue with the display of the xml elements in the middle of your question. Commented May 5, 2014 at 8:52
  • I hope the values in the xml are not real ones... because some people could find them interesting Commented May 5, 2014 at 14:57

1 Answer 1

3

Your forgot the "Payments" tag :

$xml = simplexml_load_file($filename);
foreach($xml->Payments->Payment as $value){
    echo $value->Amount;
    ......
}

You can find other examples at PHP.net

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.