I have been able to get Linq to XML to work, but I wanted to see if there was a more efficient way of applying the elements to an object rather then putting a foreach statement after I have traversed the xml? I know you can use lamba expressions, but not sure how to apply that to this or if that is possible?
Any suggestions greatly appreciated.
List<Order> myOrders = new List<Order>();
var orders = from order in xdoc.Descendants("Order")
select new{
OrderNumber = order.Element("OrderNumber").Value,
OrderDate = order.Element("OrderDate").Value,
OrderTotal = order.Element("OrderTotal").Value
};
foreach(var ord in orders)
{
myOrders.OrderNumber = ord.OrderNumber;
myOrders.OrderDate = ord.OrderDate;
myOrders.OrderTotal = ord.OrderTotal;
}