1

my xml file contains:

<studentform>
<student Studentname=" " Address=" " SSC_marks=" " Inter_marks=" " Btech_marks=" " Mailid=" "/>
<student Studentname=" " Address=" " SSC_marks=" " Inter_marks=" " Btech_marks=" " Mailid=" "/>
<student Studentname=" " Address=" " SSC_marks=" " Inter_marks=" " Btech_marks=" " Mailid=" "/>
</studentform>

iam trying to read and write this xml file in the same file, but in the output the attributes position is shuffled like this

<studentform>
<student Mailid=" " SSC_marks=" " Btech_marks=" " Studentname=" " Address=" " Inter_marks=" "/>
 <student Mailid=" " SSC_marks=" " Btech_marks=" " Studentname=" " Address=" " Inter_marks=" "/>
<student Mailid=" " SSC_marks=" " Btech_marks=" " Studentname=" " Address=" " Inter_marks=" "/>
</studentform>

it is kind of a weird problem. Any help is appreciated.

Srikanth Togara
  • 49
  • 2
  • 11

1 Answers1

1

If you are using the DOM-classes of Qt (QDomDocument, ...), then you can't do anything about it, because this happends internally (The attributes are stored in a QHash). The reason: the order of the attributes does not change the meaning of the XML-file, the information contained by the two files is the same.

If you need your attributes to be in the right order, consider using QXmlStreamWriter - This class will write attributes in the order you pass them - because it is a stream based writer. However, you will have to read and write the data with your own data-structures.

Felix
  • 6,885
  • 1
  • 29
  • 54