I promised an example of using LINQ and C# together before the month was out, and it here it is! Whoo. Go me.
Posts tagged as
My previous example only covered loading and parsing an XML document. This example will include the code I used to add new nodes to the XML tree.
So far, I have shown you how to load and parse an XML document into a C# class, and also how to add new nodes to an XML document using C#. So now we have reached the fun part: updating an existing node!
I've had a sitemap for this site for quite a while. Google (and the various other search engines) loves them some sitemaps, since it helps them crawl your site a little faster and more efficiently. For those of you wondering what a sitemap is, it is a XML document that contains an element for every public-facing page in your web site. A good sitemap follows the standard setup by Sitemaps.org, a collaboration between Google, Yahoo, and Microsoft to establish a standard sitemap format. You can deviate from the sitemap protocol if you're feeling rebellious, but the search engines will respond by ignoring your sitemap (and perhaps your site in the process).
I was working on my capstone project last semester, and ran into a need to log exception data to a portable format. I loves me some XML, so that was my obvious (and, let's be honest, only) choice. .NET includes a lot of built-in code in most data types to allow for seamless serialization, so I thought this would be a simple matter.