Sum of values question in Linq to XML

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I have this XML,
<pre class="prettyprint <BILL>
<Addresses>
<Address>
<Item>
<Charges>
<Offer>
<CreditAmount>10.00</CreditAmount>
<MonthAmount>11.00</MonthAmount>
</Offer>
<Offer>

<MonthAmount>11.00</MonthAmount>
</Offer>
<Offer>
<CreditAmount>10.00</CreditAmount>
</Offer>
<Offer>
<CreditAmount>8.00</CreditAmount>
<MonthAmount>3.00</MonthAmount>
</Offer>
</Charges>
</Item>
<Item>
<Charges>
<Offer>
<CreditAmount>10.00</CreditAmount>
<MonthAmount>11.00</MonthAmount>
</Offer>
</Charges>
</Item>
<Item>
<Charges>
<Offer>
<MonthAmount>11.00</MonthAmount>
</Offer>
</Charges>
</Item>
</Address>
</Addresses>
</BILL>[/code]
I am having to iterate each Address to do some other work but in this iterator, I want to find out the Sum of <CreditAmount> and the Sum of <MonthAmount>. Can it be done in one query so I end up with Total for CreditAmount and Total for MonthAmount.
Any help gratefully appreciated
Mike


View the full article
 
Back
Top