You can use DOM as you database. In this case QDom is the best choiche.
If you use different structure to hold your data and then re-write each time your XML, QXmlStreamWriter if better.
You can use DOM as you database. In this case QDom is the best choiche.
If you use different structure to hold your data and then re-write each time your XML, QXmlStreamWriter if better.
A camel can go 14 days without drink,
I can't!!!
ricardo (12th July 2009)
if you modify your structure of xml then qdom is better.
do not confuse it with adding data to xml..
for example suppose your xml looks like this
Qt Code:
<nodes> <child></child> <child></child> </nodes>To copy to clipboard, switch view to plain text mode
you can add or delete as many child as needed, this does not changes the xml structure, so you can use
both qdom and stream
but if you modify your xml structure like
here we have modifed the structure, this is where QDom is easy. (just make the changes and say doc->save())Qt Code:
<nodes> <child></child> <newChild></newChild> </nodes>To copy to clipboard, switch view to plain text mode
ricardo (13th July 2009)
There are two scenarios
The one MrDeath describes, you load the xml in the dom and do the chances there. Then use of course QDomDocument.
Second: You read the xml file and store all information in a custom class with QStringList, QHash etc. Your editing and chancing is done in that containers and then you want to save them, then use QXmlStreamWriter/QXmlStreamReader
ricardo (13th July 2009)
OK, thanks, I will use QDom.
Bookmarks