Hi

I have an XML generated by another computer application. The format is
as below. (Don't worry about the data in the XML. Its the test
data).

I am able to locate the correct member bill using XPATH.
However I have hit a bottleneck. I am unable to echo all the <line> elements. This is what happens

        $row = simplexml_load_string($member->asXML());

                        echo $line->particular1;
                        echo $line->amount1;
                        echo $line->particular2;
                        echo $line->amount2;

Echoes the first <line> element of the member bill. If I add the same set of statements it echoes the second <line> element and so on. But then if I put the following code which I feel is correct
        $row = simplexml_load_string($member->asXML());

                foreach ($row->line as $line);
                {
                        echo $line->particular1;
                        echo $line->amount1;
                        echo $line->particular2;
                        echo $line->amount2;
                }

Echoes only the last <line> element of the member. Can someone tell me what's wrong

-----------------The XML file -------------------------------------------------

<bill>
        <clubname>The Great Eastern Club</clubname>
        <address>Anna Road</address>
        <city>Madras</city>
        <title>BILL</title>
        <member>
                <membernumber>A00000099</membernumber>
                <billnumber>Bill no. : A00000099/APRIL 10</billnumber>
                <membername>Raman C V</membername>
                <billdate>Run date : 03/05/2010</billdate>
                <memberaddress1>NO 33,MUGAPPAIR ROAD,</memberaddress1>
                <memberaddress2>PADI,</memberaddress2>
                <membercity>CHENNAI</membercity>
                <memberpostalcode>600032</memberpostalcode>
                <memberphonenumber>9840012345</memberphonenumber>
                <preface>STATEMENT OF ACCOUNTS AND BILL FOR THE MONTH OF
APRIL-2010</preface>
                <columnh1>Particulars</columnh1>
                <columnh2>Debit</columnh2>
                <columnh3>Receivables</columnh3>
                <columnh4>Credit</columnh4>
                <line>
                        <particular1>Opening Balance</particular1>
                        <amount1>275.14</amount1>
                        <particular2>-</particular2>
                        <amount2>0.00</amount2>
                </line>
                <line>
                        <particular1>CHARGES</particular1>
                        <amount1>33.09</amount1>
                </line>
                <line>
                        <particular1>MINIMUM USAGE</particular1>
                        <amount1>220.60</amount1>
                </line>
                <line>
                        <particular1>SUBSCRIPTION CHARGES</particular1>
                        <amount1>220.60</amount1>
                </line>
                <line>
                        <particular1>WATER CHARGE</particular1>
                        <amount1>22.06</amount1>
                </line>
                <line>
                        <particular1>Total Debit</particular1>
                        <amount1>771.49</amount1>
                        <particular2>Total Credit</particular2>
                        <amount2>0.00</amount2>
                </line>
                <line>
                        <particular1>Amount to be Received</particular1>
                        <amount1>771.49</amount1>
                </line>
                <note>Hereafter no reminders will be sent for payment of
monthly/Arrears bills.</note>
        </member>
        <member>
                <membernumber>A00000100</membernumber>
                <billnumber>Bill no. : A00000100/APRIL 10</billnumber>
                <membername>Sandeep</membername>
                <billdate>Run date : 03/05/2010</billdate>
                <memberaddress1>NO 12,</memberaddress1>
                <memberaddress2>TNAGAR,</memberaddress2>
                <membercity>CHENNAI</membercity>
                <memberpostalcode>600017</memberpostalcode>
                <memberphonenumber>9840012365</memberphonenumber>
                <preface>STATEMENT OF ACCOUNTS AND BILL FOR THE MONTH OF
APRIL-2010</preface>
                <columnh1>Particulars</columnh1>
                <columnh2>Debit</columnh2>
                <columnh3>Receivables</columnh3>
                <columnh4>Credit</columnh4>
                <line>
                        <particular1>Opening Balance</particular1>
                        <amount1>496.38</amount1>
                        <particular2>-</particular2>
                        <amount2>0.00</amount2>
                </line>
                <line>
                        <particular1>ENTERTAINMENT CHARGES</particular1>
                        <amount1>33.09</amount1>
                        <particular2>17/06/2010 CASH 
PCR/000544/10-11</particular2>
                        <amount2>124.00</amount2>
                </line>
                <line>
                        <particular1>MINIMUM USAGE</particular1>
                        <amount1>124.00</amount1>
                </line>
                <line>
                        <particular1>SUBSCRIPTION CHARGES</particular1>
                        <amount1>220.60</amount1>
                </line>
                <line>
                        <particular1>WATER CHARGE</particular1>
                        <amount1>22.06</amount1>
                </line>
                <line>
                        <particular1>Total Debit</particular1>
                        <amount1>896.13</amount1>
                        <particular2>Total Credit</particular2>
                        <amount2>124.00</amount2>
                </line>
                <line>
                        <particular1>Amount to be Received</particular1>
                        <amount1>772.13</amount1>
                </line>
                <note>Hereafter no reminders will be sent for payment of
monthly/Arrears bills.</note>
        </member>
</bill>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to