Results 1 to 5 of 5

Thread: Order of attributes in QDomElement

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Order of attributes in QDomElement

    I create with the QDomDocument several QDomElements:

    Qt Code:
    1. QDomElement bams = domDoc.createElement("BAMS");
    2. bams.setAttribute("rippleFilter", m_nRifi);
    3. bams.setAttribute("rangeShifter", m_nRashi);
    4. bams.setAttribute("rangeShifterDistance", m_lfRaShiDistance);
    5.  
    6. domNode.appendChild(bams);
    7.  
    8. QDomElement table = domDoc.createElement("TxTable");
    9. table.setAttribute("roll", m_fRoll);
    10. table.setAttribute("pitch", m_fPitch);
    11. table.setAttribute("lateral", m_fLateral);
    12. table.setAttribute("longitudinal", m_fLongitudinal);
    13. table.setAttribute("isocentricAngle", m_fIsoAngle);
    14. table.setAttribute("vertical", m_fVertical);
    15.  
    16. domNode.appendChild(table);
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Order of attributes in QDomElement

    Not using QDomDocument.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3

    Default Re: Order of attributes in QDomElement

    Well, thank you for the fast reply.
    What can I use then?

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Order of attributes in QDomElement

    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.

  5. #5

    Default Re: Order of attributes in QDomElement

    This means that no application should impose such constraints (at least is not in XML standards imposed). Ok. So I'll live with it.

Similar Threads

  1. How to change the attributes of a file
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2010, 17:26
  2. XML Getting attributes of a specific value
    By di_zou in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2009, 12:04
  3. Attributes order in QDomElement
    By ixSci in forum Qt Programming
    Replies: 3
    Last Post: 21st August 2009, 13:52
  4. QDomElement
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2007, 12:55
  5. Profile Attributes
    By joy in forum Newbie
    Replies: 1
    Last Post: 8th September 2006, 16:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.