When QDomDocument
reads XML elements that consist only of whitespace, it reads an empty element. This answer provides a solution to the problem, using QXmlSimpleReader
, and QXmlInputSource
. But these classes are now deprecated (at least as of Qt 5.15).
The docs for QDomDocument::setContent
now recommend using QXmlStreamReader
. But when I do this, I again lose my whitespace:
QXmlStreamReader xmlReader(&file); /// successfully-opened QFile
QString errorString;
int line, column;
bool result = mDomDocument->setContent(&xmlReader, false, &errorString, &line, &column);
if( ! result )
{
qCritical() << "XML Read Error, Line " << line << ", Column " << column << ": " << errorString;
}
From the above I get no warnings, and no whitespace.:-)
Is this a bug or am I doing something wrong?