PDA

View Full Version : Order of attributes in QDomElement



g_iancu
4th November 2010, 15:30
I create with the QDomDocument several QDomElements:


QDomElement bams = domDoc.createElement("BAMS");
bams.setAttribute("rippleFilter", m_nRifi);
bams.setAttribute("rangeShifter", m_nRashi);
bams.setAttribute("rangeShifterDistance", m_lfRaShiDistance);

domNode.appendChild(bams);

QDomElement table = domDoc.createElement("TxTable");
table.setAttribute("roll", m_fRoll);
table.setAttribute("pitch", m_fPitch);
table.setAttribute("lateral", m_fLateral);
table.setAttribute("longitudinal", m_fLongitudinal);
table.setAttribute("isocentricAngle", m_fIsoAngle);
table.setAttribute("vertical", m_fVertical);

domNode.appendChild(table);


The output is:



<BAMS rangeShifterDistance="0" rippleFilter="0" rangeShifter="0"/>
<TxTable vertical="0" longitudinal="0" lateral="0" isocentricAngle="0" pitch="0" roll="0"/>


Is there any possibility to preserve the order of attributes?

wysota
4th November 2010, 15:38
Not using QDomDocument.

g_iancu
4th November 2010, 22:13
Well, thank you for the fast reply.
What can I use then?

SixDegrees
4th November 2010, 22:35
XML doesn't care about the order of attributes, and doesn't guarantee any particular order. The order they appear in is most likely an artifact of whatever data structure is used internally to store them.

There is no point in trying to enforce an order in terms of processing; the parser doesn't care. Neither should any output routines - specifications demanding a particular ordering are misguided, at best.

g_iancu
5th November 2010, 07:49
This means that no application should impose such constraints (at least is not in XML standards imposed). Ok. So I'll live with it.