From the XML Document
<?xml version="1.0" encoding="utf-8" ?>
<Data>
<Products>
<Product ProductId="1001" ProductName="ProductA" ProductPrice="123.45" />
<Product ProductId="1002" ProductName="ProductB" ProductPrice="100.45" />
</Products>
....
How to use "Sum" to find the sum of ProductPrice?
When i use
XDocument doc = XDocument.Load("Product.xml");
var sum =
from tot in (int)doc.Descendants("Product").
Attributes("ProductPrice").Sum()
select tot;
I receive Error : "can not convert type system.xml.linq.xmlattribute to int".