Hi all
I am creating a .xml file and write in it but the contents are not written to it. I am coding like this
const int Indent = 4;
QDomElement translation
= doc.
createElement("translation");
QDomText latin
= doc.
createTextNode("Ars longa vita brevis");
QDomText english
= doc.
createTextNode("Art is long, life is short");
doc.appendChild(root);
root.appendChild(quote);
root.appendChild(translation);
quote.appendChild(latin);
translation.appendChild(english);
qDebug()<<"error";
QDomNode xmlNode
= doc.
createProcessingInstruction("xml",
"version=\"1.0\" encoding=\"ISO-8859-1\"");
doc.insertBefore(xmlNode, doc.firstChild());
ts << doc.toString();
doc.save(ts, Indent);
file->close();
const int Indent = 4;
QDomDocument doc;
QDomElement root = doc.createElement("doc");
QDomElement quote = doc.createElement("quote");
QDomElement translation = doc.createElement("translation");
QDomText latin = doc.createTextNode("Ars longa vita brevis");
QDomText english = doc.createTextNode("Art is long, life is short");
doc.appendChild(root);
root.appendChild(quote);
root.appendChild(translation);
quote.appendChild(latin);
translation.appendChild(english);
QFile *file = new QFile("E:\test.txt");
if(!file->open(QIODevice::WriteOnly))
qDebug()<<"error";
QTextStream ts(file);
QDomNode xmlNode = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"ISO-8859-1\"");
doc.insertBefore(xmlNode, doc.firstChild());
ts << doc.toString();
doc.save(ts, Indent);
file->close();
To copy to clipboard, switch view to plain text mode
Please tell me what i am doing wrong, i am not able to view my file.
Thanks for help.
Added after 6 minutes:
I solved the problem.
Sorry.
Bookmarks