var query = from c in data.DescendantsAndSelf("customer")
which as Mike said, involves a bit too much of hoping and praying (relying on no underlying changes, no strong typing etc).However, I'm really encouraged by the idea of Linq to XSD which seems like a much better idea, tying the query to a schema rather than a document.Fabrice has some sample code based on Linq to XML and Linq to XSD as follows, which goes to show the improvement using the XSD versionHere is a LINQ to XML query:
from item in purchaseOrder.Elements("Item")
select (double)item.Element("Price") * (int)item.Element("Quantity")Here is the same query as above, but written using LINQ to XSD:
from item in purchaseOrder.Item
select item.Price * item.Quantity
which I think looks much more elegant and less clunky.