![]() Registered Member ![]()
|
I wrote an xml file with the class QXmlWriter, here is the code:
QXmlStreamWriter* xmlWriter = new QXmlStreamWriter(); xmlWriter->setDevice(&file); xmlWriter->writeStartDocument(); xmlWriter->writeStartElement("notes"); xmlWriter->writeStartElement("note"); xmlWriter->writeAttribute("data","15/07/2010); xmlWriter->writeCharacters ("here is the note"); xmlWriter->writeEndElement(); } xmlWriter->writeEndElement(); xmlWriter->writeEndDocument(); delete xmlWriter; } this code works,and this is the result: <?xml version="1.0" encoding="UTF-8"?> <Notes> <note date="mer ago 11 2010" >text note</note> </Notes> now the xml file is closed by </Notes> and i can't understand how can i add another element...(i mean <note date="gio ago 12 2010" >text note</note>) before the closing tag. |
![]() Administrator ![]()
|
The following code should work.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
Yes, this code works. Imagine now that you want to modify the xml file, the Document has been closed, and i can't add another element..
|
![]() Administrator ![]()
|
You will need to read ( parse ) the xml back into your application, then add the data and write it back out again.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]