Well, that didn’t take long: Eric White has already posted a series of blog posts on using Linq to XML with Open XML. He covers the basics of packages and parts, and then presents an OpenXMLDocument class that converts any Open XML document into a hierarchical object graph on which it is easy to write LINQ to XML queries. An XDocument XML is created for each part in the package, and you can then write LINQ to XML queries over multiple parts easily.
From the comment thread on Eric’s blog, I learned that James Newton-King has also posted a Ling to XML sample for Open XML development. An idea whose time has come, apparently!
James’s “Linq to XML over large documents post” focuses more on the performance aspects of Linq to XML, and how it provides for a smaller memory footprint than a DOM-based approach. He describes how you can combine Linq to XML with XMLReader to get the best of both worlds: flexible and simple development, and minimal memory usage resulting in great performance.
If you’re interested in learning a lot more abobut how Linq to XML can help streamline your Open XML development work, be sure to add these two blogs to your RSS feeds: