i code doesn’t work if i want to append it…..
here is my code…
QDomDocument document;
QDomElement root = document.createElement("main");
document.appendChild(root);
QDomElement book = document.createElement("book");
book.setAttribute("Name ", ui->lineEdit->text());
book.setAttribute("ID ",ui->lineEdit1->text());
root.appendChild(book);
QFile file("E:/z.xml");
if(!file.open(QIODevice::Append | QIODevice::Text ))
{
qDebug() <<"Failed to open file ";
// return -1;
}
else
{
QTextStream stream(&file);
stream << document.toString();
file.close();
qDebug() <<"finished";
}
[add code markup, Tobias]
↧