Hi:
Say the xml is like this:
<Root>
<LowestNewPrice>
<Amount>1519</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$15.19</FormattedPrice>
</LowestNewPrice>
<LowestNewPrice>
<Amount>1519</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$9.09</FormattedPrice>
</LowestNewPrice>
<LowestNewPrice>
<Amount>1519</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$21.14</FormattedPrice>
</LowestNewPrice>
<LowestNewPrice>
<Amount>1519</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$5.00</FormattedPrice>
</LowestNewPrice>
<LowestNewPrice>
<Amount>1519</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$17.13</FormattedPrice>
</LowestNewPrice>
</Root>
You can try:
XDocument xmlProducts = XDocument.Load("uri_of_xml_file");
var products = from ItemAttributes in xmlProducts.Descendants("LowestNewPrice")
select new
{
Price = ItemAttributes.Element("FormattedPrice").Value
}
;
var result =products.OrderBy(r =>Convert.ToDouble(r.Price.Substring(1,r.Price.Length-1))).ToList();
I suggest you to learn two concepts: lambda expression and extension methods, which are very important in Linq.
http://msdn.microsoft.com/en-us/library/bb397687.aspx
http://msdn.microsoft.com/en-us/library/bb675269.aspx
Regards
Sincerely,
Allen Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.