[SOLVED] Save QDomDocument to xml
-
Once built a QDomDocument
@
QDomDocument doc("MyML");
QDomElement root = doc.createElement("MyML");
doc.appendChild(root);QDomElement tag = doc.createElement("Greeting");
root.appendChild(tag);QDomText t = doc.createTextNode("Hello World");
tag.appendChild(t);QString xml = doc.toString();
@how can I save it to an xml file?
-
You can use "QTextStream":http://qt-project.org/doc/qt-5/qtextstream.html
-
hi
Writing a DOM document to a file
@
QFile file( "simple.xml" );
if( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
{
qDebug( "Failed to open file for writing." );
return -1;
}
QTextStream stream( &file );
stream << document.toString();
file.close();
@