I get to see quite a bit of XML, and my path in the past has always been to use LINQ to iterate through the document and read it into a class. Then I’d use the class to do whatever work I need to do.
This code takes advantage of the XmlSerializer.Deserialize method. It will take the XML document an turn it into a .NET class.
To run this code, create a Windows Forms application and drop this code into the form code behind. It is complete and should run unmodified.
Note that the OrderedItem class and the getXMLDoc function both make use of namespaces for two of the elements, so we show how to code this both with and without namespace references.