[Qt-interest] QDomNode and save to stream

Petric Frank pfrank at gmx.de
Sat Jan 31 01:52:28 CET 2009


Hello,

dumping QDomElement items (using the save method) having attributes it should 
output as

<Name attr="value"> ...

but instead i get

<Name attr="value" > ...

(note the blank before the greater-than sign)

I tracked it down to the source location. The problem sems to be in the file 
src/xml/dom/qdom.cpp in the method

void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const

where the attributes are streamed one ofter the other. The logic writes a 
blank in case of any attributes to handle. Then for each handle write the 
attribute and append another blank.
This results in an superflous blank at the end.

The solution would be to move the first

s << ' ';

two lines later (as first statement inside the loop) and remove the second 
one.

This bug is in qt 4.4.3 and 4.5.0-beta1.

This report looks like a bit nitpicking but i have an application (no source 
available) reading this generated xml file. It jokes on that additional 
blank.

Hope that helps.

regards
  Petric
 



More information about the Qt-interest-old mailing list