blob: ccf536c41340d33765270cff47b57e95df6ba602 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QCoreApplication>
#include <QFile>
#include <QXmlStreamWriter>
#include <stdio.h>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QFile output;
output.open(stdout, QIODevice::WriteOnly);
//! [write output]
//! [start stream]
QXmlStreamWriter stream(&output);
stream.setAutoFormatting(true);
stream.writeStartDocument();
//! [start stream]
stream.writeDTD("<!DOCTYPE xbel>");
stream.writeStartElement("xbel");
stream.writeAttribute("version", "1.0");
stream.writeStartElement("folder");
stream.writeAttribute("folded", "no");
//! [write element]
stream.writeStartElement("bookmark");
stream.writeAttribute("href", "http://qt-project.org/");
stream.writeTextElement("title", "Qt Project");
stream.writeEndElement(); // bookmark
//! [write element]
stream.writeEndElement(); // folder
stream.writeEndElement(); // xbel
//! [finish stream]
stream.writeEndDocument();
//! [finish stream]
//! [write output]
output.close();
return 0;
}
|