Is this what you recommend?
void test_save() {
QXmlStreamWriter stream(&output);
stream.writeStartDocument();
stream.writeStartElement("a");
output.write(b.toLatin1().constData(), b.length());
stream.writeEndElement();
stream.writeEndDocument();
output.close();
qDebug("%s", bytes.data());
}
void test_save() {
QString b = "<b>test 1 2 3 </b>";
QByteArray bytes;
QBuffer output(&bytes);
output.open(QIODevice::ReadWrite);
QXmlStreamWriter stream(&output);
stream.writeStartDocument();
stream.writeStartElement("a");
output.write(b.toLatin1().constData(), b.length());
stream.writeEndElement();
stream.writeEndDocument();
output.close();
qDebug("%s", bytes.data());
}
To copy to clipboard, switch view to plain text mode
This outputs:
<?xml version="1.0" encoding="UTF-8"?><a<b>test 1 2 3 </b>/>
<?xml version="1.0" encoding="UTF-8"?><a<b>test 1 2 3 </b>/>
To copy to clipboard, switch view to plain text mode
See how "a" element is not closed? Note also how the "</a>" is missing, as well as document end. I wonder why it broke off so much.
Bookmarks