Process XML with C#

Even if you aren’t a C# programmer, you can get up to speed on processing XML with C# in short order with this hack.

C# is an object-oriented programming language that comes as part of Microsoft’s .NET framework (, which was introduced in 2000. C# has taken a lot of lessons from C, C++, and Java, but I won’t get into a comparison of these languages here. (For a good discussion of this, see Dare Obasanjo’s “A Comparison of Microsoft’s C# Programming Language to Sun Microsystems’ Java Programming Language” at Like any programming language, C# has it proponents and opponents. While I still use Java the most, when XML is concerned, I fall into the camp of C# proponents.

My objective here is to introduce some of C#’s programming facilities for XML, which are legion. C# offers oodles of APIs for you to scratch just about any XML itch you can find. This hack will exercise several programs that use a few of these APIs, enough to get you started writing your own C# programs for processing XML.

Getting C#

C# is compiled into an intermediate code, so you need to have .NET or Mono on your system to even get a compiled C# program to work. You can get C# in several ways. If you are working on Windows, you can download .NET from Microsoft’s MSDN site ( or through; or, if you are on Windows or Linux (Red Hat, Debian, ...

Get XML Hacks now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.