XML – Meh!

On 2011/01/01, in Programming, by Greg Woods

I’ve never been a fan of XML. The first time I came across it was around 2001 working for an ISP. We received press releases from the Press Association (or ‘Ananova’ as it was briefly back then) in XMLformat and had to translate them to HTML snippets. After a little investigation as to what was available at the time, and asking some of the more senior developers, I came to the conclusion that the best way to parse these files was using Perl regular expressions. It was primitive, very effective, and easy enough to rewrite should the format change.

Well, there have been all sorts of attempts at making XML easier to use. There are frameworks galore, and a whole new language – XSLT. The proponents of these methods are generally under the illusion that all devs are like them, and dream in XML format. The truth is, most of us will use the format only when necessary, and really, really do not want to learn XSLT.

In my current side project, a windows app for configuring joystick settings in Flight Simulator, I’ve decided to use XML to save the settings. This is one use of XML I approve of. It is good for hierarchies, and the files can be hand edited by advanced users.

I do not however, want to be messing about directly with the XML in my application. So, I’ve been playing around with derializing* the XML config settings into an object hierarchy – which my application will use, before serializing* back to XML for saving.

As a whole new area to me, I was expecting a steep learning curve. Some well read articles from around 2006 stated that it wasn’t straightforward if you had list of objects (IEnumerables) in your object hierarchy. It turns out, in 2010, using .NET 4.0 (maybe earlier versions too), it works well with no special tweaking.

My next two posts will show examples which can be pasted straight into Linqpad.

*U.S. spelling used, because that’s the language of the .NET framework

Tagged with:  

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>