View Full Version : XML file writing

24th May 2006, 17:16
I am reading in an XML file using QDomElement and everything is working fine. My problem is when I write the xml out after changes, the attributes in my elements are not getting printed in the order that I want them.

This is the order in which I have my file setup:

<var name="width" value="3" units="m" />

And this is the order in which the are written:

<var units="m" value="3" name="width" />

I was wondering if I can specifiy the order in which the attributes are written.


24th May 2006, 18:05
Just curious, why do you even care about the order? :)

As far as I remember, QDomElement stores it's attributes in an unordered hash and it surely does not care about the order of the attributes. Since QDom* classes in general have no virtual methods, you might have to implement the recursive writing all by yourself.

24th May 2006, 20:04
The reason I care about the order is my program is going to be used by other people who want to quickly look at the data file (XML file) without loading the program and figure out which values were changed. And one of the nice things would be to see the name of the value first, then the value and then the units.