Episode 12 of Visual Studio Toolbox (Using LINQ to XML to Write XML) is now live


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.

LINQToXMLDemo.zip


Comments (2)

  1. Chris says:

    Hi, in the XDeclaration there was a UTF-16 parameter and after saveing the file the xml contained UTF-8, why is that ?

  2. M says:

    Hi Robert–  Excellent videos.  Like these two on XML and LINQ.  And I like the ones you've done on Lightswitch.  Please keep 'em coming.  Great job.  

Skip to main content