PDA

View Full Version : update the xml file from QT program



rk0747
28th January 2010, 06:33
hi , i am begginer in Qt . i unable to update and delete the data in an xmlfile using the Qt application. please can anybody tell me how to solve my problem. Attaching the xmledit file. please find the attachment.

aamer4yu
28th January 2010, 07:52
Well, working with QDomDocument is easier.
QDomDocument::setContent and QDomDocument::toString might be what you need to read and write xml.

rk0747
28th January 2010, 10:17
sir,
i have five .ui forms. Total .ui forms information should store in a single xml file. can we do this using QDomDocument?

arvind_jki
28th January 2010, 11:55
Yes it is possible.
First decide a XML format with initial data if necessary otherwise with blank data. Create in memory view of this XML and ensure all read write by ui forms are done in this XML(QDomDoc). At the time of applicatio exit save the content of this XML to file.

QDomDocument doc("mydocument");
QFile file("mydocument.xml");

file.open(QIODevice::ReadOnly)


doc.setContent(&file)
file.close();

//.........
// Modify your XML here
//.........


QString savedXML=doc.toString();
QTextStream tempTS(&savedXML);
dom.save(tempTS,0);

rk0747
28th January 2010, 13:58
ok, but i am very new to QdomDocument and i saw some examples i did n't understood due to more files and big code, please if u possible can u send me how to create and retrive the data from xml using QDomdocument or any sample code .
i am struggling for this from 3 weeks .please help me.

Thanks

boudie
28th January 2010, 18:20
Download this book:
http://www.qtrac.eu/C++-GUI-Programming-with-Qt-4-1st-ed.zip
and start reading from page 344.
It won't get easier than this... ;)