I reformatted the xml to this:
<?xml version="1.0" encoding="utf-8"?>
<body>
<Order>
<OrderDate>2012-08-08T09:40:00</OrderDate>
<Extensions>
<WebOrder>true</WebOrder>
</Extensions>
<OrderLine Action="Add" TypeCode="New" TypeDescription="New Item">
<Product>
<ProductId>1234</ProductId>
</Product>
</OrderLine>
<OrderLine Action="Add" TypeCode="New" TypeDescription="New Item">
<Product>
<ProductId>9876</ProductId>
</Product>
</OrderLine>
</Order>
</body>
And then ran this code:
XElement _x = XElement.Load(@"order.xml");
var orders = from el in _x.Elements("Order") select el;
foreach (var order in orders)
{
Debug.Print(order.Element("OrderDate").Value);
}
You could clean up the XML in an automated way like this:
XDocument doc = XDocument.Load("order.xml");
foreach (var node in doc.Root.Descendants()
.Where(n => n.Name.NamespaceName == "urn:schemas-basda-org:2000:purchaseOrder:xdr:3.01"))
{
node.Attributes("xmlns").Remove();
node.Name = node.Parent.Name.Namespace + node.Name.LocalName;
}
Debug.Print(doc.ToString());