Listing 1: Convert XPath into LINQ to XML: XML: Build a Basic Structure
XML structures vary widely in arrangement, complexity, and whether the data is held in content or attributes. A variation of this sample XML is used throughout this article.
<?xml version="1.0" encoding="utf-8"?>
<!-- From Microsoft Sample Files with a namespace
added -->
<Root xmlns="http:CustomersAndOrder">
<Customers>
<Customer CustomerID="GREAL">
<!-- Etc. -->
<FullAddress>
<Address>2732 Baker Blvd.</Address>
<City>Eugene</City>
<!-- Etc. -->
</FullAddress>
</Customer>
<!-- Etc. -->
</Customers>
<Orders>
<Order>
<!-- Etc. -->
<ShipInfo ShippedDate=
"1997-05-09T00:00:00">
<!-- Etc. -->
<ShipRegion>OR</ShipRegion>
</ShipInfo>
</Order>
<!-- Etc. -->
</Orders>
</Root>