开发者

Sorting an XML file with Qt

开发者 https://www.devze.com 2022-12-15 12:31 出处:网络
how to to sort an XML file using Qt my file look like this : <?xml version=\"1.0\" encoding=\"UTF-8\"?开发者_Go百科>

how to to sort an XML file using Qt

my file look like this :

<?xml version="1.0" encoding="UTF-8"?开发者_Go百科>
<project>
    <task next="2" first="1" name="2" value="name1"/>
    <task next="3" first="1" name="1" value="name2"/>
    <task next="4" first="3" name="4" value="name3"/>
    <task next="4" first="1" name="6" value="name4"/>
    <task next="5" first="2" name="3" value="name5"/>
    <task next="5" first="4" name="5" value="name6"/>
</project>

Thanks.


Basically, you need to parse the XML file into a set of records, sort the records on the appropriate field, then write the result back out as a new XML file. There are zillions of XML parsers out there that are intended to make it easy for you to parse the data. Personally, I've always written my own code to handle it. It's almost as fast to write, and executes quite a bit faster -- but that's me, and the XML I've parsed this was has mostly been fairly simple. If you lack experience at writing parsers and/or don't care as much about execution speed, chances are that using an existing parser will be a better choice.


What do you mean by sorting an xml file?
I think this needs a bit more thought.

Either sort the values after you read them from the file in your app or to work on the XML file directly You may wish to look into xslt.

0

精彩评论

暂无评论...
验证码 换一张
取 消