Hi rakkar,
To you save your config file or other things in xml format, you can use QXmlStreamWriter. Read about this class and QtXml Module
Example:
return(FALSE);
QString manifestNS
= QString::fromLatin1("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
QXmlStreamWriter stream(&f);
stream.setAutoFormatting(true);
stream.
writeNamespace(manifestNS,
QString::fromLatin1("manifest"));
stream.writeStartDocument();
stream.
writeStartElement(manifestNS,
QString::fromLatin1("manifest"));
stream.
writeEmptyElement(manifestNS,
QString::fromLatin1("file-entry"));
stream.
writeAttribute(manifestNS,
QString::fromLatin1("media-type"),
QString::fromLatin1("application/vnd.oasis.opendocument.spreadsheet"));
stream.
writeAttribute(manifestNS,
QString::fromLatin1("version"),
QString::fromLatin1("1.2"));
stream.
writeAttribute(manifestNS,
QString::fromLatin1("full-path"),
QString::fromLatin1("/"));
stream.
writeEmptyElement(manifestNS,
QString::fromLatin1("file-entry"));
stream.
writeAttribute(manifestNS,
QString::fromLatin1("media-type"),
QString::fromLatin1("text/xml"));
stream.
writeAttribute(manifestNS,
QString::fromLatin1("full-path"),
QString::fromLatin1("content.xml"));
stream.writeEndElement(); // end manifest:manifest
stream.writeEndDocument();
QFile f(_fileManifest);
if(!f.open(QIODevice::WriteOnly | QIODevice::Text))
return(FALSE);
QString manifestNS = QString::fromLatin1("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0");
QXmlStreamWriter stream(&f);
stream.setAutoFormatting(true);
stream.writeNamespace(manifestNS, QString::fromLatin1("manifest"));
stream.writeStartDocument();
stream.writeStartElement(manifestNS, QString::fromLatin1("manifest"));
stream.writeEmptyElement(manifestNS, QString::fromLatin1("file-entry"));
stream.writeAttribute(manifestNS, QString::fromLatin1("media-type"), QString::fromLatin1("application/vnd.oasis.opendocument.spreadsheet"));
stream.writeAttribute(manifestNS, QString::fromLatin1("version"), QString::fromLatin1("1.2"));
stream.writeAttribute(manifestNS, QString::fromLatin1("full-path"), QString::fromLatin1("/"));
stream.writeEmptyElement(manifestNS, QString::fromLatin1("file-entry"));
stream.writeAttribute(manifestNS, QString::fromLatin1("media-type"), QString::fromLatin1("text/xml"));
stream.writeAttribute(manifestNS, QString::fromLatin1("full-path"), QString::fromLatin1("content.xml"));
stream.writeEndElement(); // end manifest:manifest
stream.writeEndDocument();
To copy to clipboard, switch view to plain text mode
The result will be:
<?xml version="1.0" encoding="UTF-8"?>
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
<manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.spreadsheet" manifest:version="1.2" manifest:full-path="/"/>
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
</manifest:manifest>
<?xml version="1.0" encoding="UTF-8"?>
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
<manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.spreadsheet" manifest:version="1.2" manifest:full-path="/"/>
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
</manifest:manifest>
To copy to clipboard, switch view to plain text mode
Bookmarks