The unwritten law of XML parsing

Project, Programming Send feedback »

I've spent the past I guess week trying different forms of data parsing, from the obvious ones like TinyXML and Xerces to ones that tried to surprise me with a $250 license for commercial use (and the ability to write XML files with). I eventually out of frustration succumbed to the though of using two different parsers, XML Lite the Microsoft XML Parser/Writer and when I could be bothered some form of cross platform XML parser.

So, Friday morning I spent a good half an hour I guess writing a nice XML write map to file and it worked flawlessly. Then I spent the rest of the day trying to parse it...but failing miserably, attempting to botch off the example on MSDN first storing my data as attributes (which meant the file was about 8kb), but no it wouldn't let me get to my attributes so I then wrote them as values (which increased the file size by a little more than 2x) but then a few nodes in I would get a run time error for attempting to access an empty wchar* string when that should contain the first of the tag names I would be comparing for to then pull the values and construct the object.

While looking about Friday night (when I discovered CMarkup the fantastic parser albeit unfortunately pricey which big global companies get to use) I noticed one other advertised as small XML parser here which I kept a bookmark to in case worst come I need to write for a third time a function to pull my map data from XML, so on Saturday within minutes of receiving the link for the parser by email I had accomplished more parsing than hours of work with XML Lite and in about 250 less lines of code...

This begs the question as to why we have so many XML Parsing libraries that are stupidly difficult to use (or expensive for hobbyists) and so few that make use of C++ idioms such as RAII, therefore requiring you to juggle pointers that potentially cause run time errors that are cryptic. It is the very same reason that makes all of the standard template library and boost library so good, it doesn't ask too much of you to integrate it into your work.

Contact. ©2012 by Adam Anderson. blog software / web hosting / monetize.
Design & icons by N.Design Studio. Skin by Tender Feelings / Evo Factory.