Please nominate your Qt Champions for 2021!

QDomDocument setContent shakes attributes

  • I've got some troble reading xml file with a QDomDocument setContent method. It shakes my atrributes in random order. I write xml useing text stream. Then open it by some editors and saw the right order of atrributes. But when I open it using setContent method and save the result, my attributes are in other order than previously.

  • hii Antlcross,

    Setcontent returns true whether an XML data is availabele from the DOM tree. If not, the XML file was not valid.
    Means it is just for checking whether an XML file valid or invalid.

    Hope it will help you.

  • Thanks, lam Sumit. I found the reason. When I'm reading xml file I use QDomDocument. And actually I use attributes() metod of QDomNode to get attributes of node. But if I use that method my attributes will sort in map in random order. So how can I fix that ? Or are thre other ways to get attributes frome node without sequence error ?

Log in to reply