1

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?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
adam.baker
  • 1,447
  • 1
  • 14
  • 30

1 Answers1

0

This is a known bug (or undocumented feature) and will apparently be fixed in Qt 6.5.

adam.baker
  • 1,447
  • 1
  • 14
  • 30