Previously on Visual Studio Toolbox, I showed how to use LINQ to XML to query data from Web sites. In this episode, I show how to use LINQ to XML to write XML. I start with a simple example that stores personal settings in an XML file, and then retrieves wines from Wine.com and writes them to an XML file. This provides offline storage of the wines data. (You can think of this as the second half of our review of LINQ to XML, but last week’s episode was a robust 40 minutes long while this one is a crisp 15. So it’s really more like the last quarter!)
You can find this episode at https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Visual-Studio-Toolbox-Using-LINQ-to-XML-to-Write-XML or watch it here. The code I used is attached for your viewing and coding pleasure. Note that this code includes both the reading data from the Web from last time and the writing XML code from this time.