Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.9.1
-
None
Description
The code:
QString output1; QXmlStreamWriter stream1(&output1); stream1.setAutoFormatting(true); stream1.writeStartDocument(); stream1.writeStartElement("tag"); //stream2.writeCharacters(QString()); stream1.writeEndElement(); stream1.writeEndDocument(); QString output2; QXmlStreamWriter stream2(&output2); stream2.setAutoFormatting(true); stream2.writeStartDocument(); stream2.writeStartElement("tag"); stream2.writeCharacters(QString()); stream2.writeEndElement(); stream2.writeEndDocument(); QString output3; QXmlStreamWriter stream3(&output3); stream3.setAutoFormatting(true); stream3.writeStartDocument(); stream3.writeTextElement("tag", QString()); stream3.writeEndDocument(); qDebug() << output1; qDebug() << output2; qDebug() << output3;
Produces:
"<?xml version=\"1.0\"?>\n<tag/>\n" "<?xml version=\"1.0\"?>\n<tag></tag>\n" "<?xml version=\"1.0\"?>\n<tag></tag>\n"
I would expect output2/output3 to be the same as output1, i.e. with a self-closing tag. The only difference is the additional call of writeCharacters(QString()).
Obviously, output3 is the same as output2 because writeTextElement is just a convenience function.