iTunes Playlists to Xml: Parsing categories with LINQ

  • October 20, 2010
  • James Skemp
I recently had the need to determine what types of music I had within my collection of music. Since I created iTunes Playlists to Xml so that I could export out my library on my iPod, it was easy enough to run that and then open LINQPad to run the following query. Obviously, you must export the Genre field in order for the following query to work. // Location to the XML from iTunes Playlists to XML String playlistXml = @"

Read More

Vehicle gas DTD .NET objects and XML parsing with LINQ

  • June 10, 2010
  • James Skemp
The code contained below is a rough draft, and will eventually be moved into an assembly, and the code posted. At some point in 2007 I started keeping track of my gas mileage in an XML file, with a custom DTD for validation (and intellisense in oXygen). I present below the code necessary to create an rough object from the XML, and the LINQ to parse it out. C# objects public class Vehicle { public int Id { get; set; } public String Make { get; set; } public String Model { get; set; } public int Year { get; set; } public IEnumerable Fillups { get; set; } } public class Fillup { public int Id { get; set; } public DateTime Date { get; set; } public int MilesTotal { get; set; } public Decimal MilesDriven { get; set; } public Decimal Gallons { get; set; } public Decimal CostPerGallon { get; set; } public Decimal CostTotal { get; set; } public String Notes { get; set; } }</code></pre> LINQ to XML XDocument vehicleGasXml = XDocument.

Read More

Determine BlogEngine.NET comments that haven't been published - with LINQPad

  • December 31, 2009
  • James Skemp
At the beginning of the month I wrote a post on how to find BlogEngine.NET comments that had not yet been published/approved. Having purchased a copy of LINQPad a short while ago (autocompletion costs, the program with all other functionality does not; give it a try if you develop in .NET - it's very cool), and having got slammed this morning with some spammer who had an hour to kill, I decided to adapt my code for LINQPad.

Read More

Determine BlogEngine.NET comments that haven't been published

  • December 6, 2009
  • James Skemp
Unfortunately, BlogEngine.NET doesn't currently have a very good way to determine, at a glance, all of the comments that haven't been approved. While this will certainly be coming in a future release, or as an extension, I figured writing something simple to do this would be a good LINQ to XML test for me. You can download the built executable, or play with the code, which is included below. Download the executable (7-Zip format).

Read More

Parsing Yahoo! Music's Artist Web Services with C# and LINQ to XML - Search for artists

  • September 12, 2009
  • James Skemp
Similar to my post on parsing Last.fm's artist.getSimilar, I've been working with Yahoo! Music's Web services today. Unfortunately, Yahoo!'s services aren't quite as friendly as those made available by Last.fm. So that I remember, and others don't have to tackle this as well, here's the class I've created. (Download JamesRSkemp.WebServices.YahooMusic.cs.) /* Created by James Skemp - http://jamesrskemp.com/ Version 1.0 More information at http://strivinglife.com/words/post/Parsing-Yahoo!-Musics-Artist-Web-Services-with-C-and-LINQ-to-XML-Search-for-artists.aspx Shared under a Creative Commons Attribution 3.0 United States License - http://creativecommons.

Read More

Parsing Last.fm Web Services' artist.getSimilar with C# and LINQ to XML

  • September 12, 2009
  • James Skemp
The following covers how to parse the XML response of artist.getSimilar, from Last.fm's Web Services. Setup and assumptions The first step is sign up for a free API account at Last.fm. You'll also need to target .NET Framework 3.5 when you setup your project, so as to access LINQ functionality. When writing the steps listed below, I was working on a Windows Forms Application, but the steps should be the same, or very similar, for other project types.

Read More