I've used XML before but this week was the first time that I did a complete XML design: decided on the configuration file format, wrote reader for it and wrote the writer for it.

Writing XML is simpler than reading it - no parsing is involved. My code is C++ with Qt, so I could use their DOM to write an XML tree. Now, it's nice when you read in a tree with DOM, modify it and write it back, but creating a DOM tree for scratch is a pain.

Qt realized this so they created a simple XmlWriter class (not an "official" Qt class) that abstracts some of the redundancies of manual writing. It's versatile, simple and powerful.

Reading XML is difficult and one has to use a specialized library for that. DOM is simpler to use in most cases, but SAX is faster. I didn't need speed so I resolved to DOM.

One weirdness of Qt's DOM implementation (which, they say, mimics the Java implementation) is that converting QDomNode to QDomElement (a father to child conversion) with toElement() requires non-constness of the QDomNode. Which means that passing around const references to QDomNode to functions is inconvenient.


comments powered by Disqus