Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QXmlFormatter Class Reference
[
QtXmlPatterns module]

The QXmlFormatter class indents and pretty-formats XML events. More...

 #include <QXmlFormatter>

Inherits QXmlSerializer.

Note: All the functions in this class are reentrant.

This class was introduced in Qt 4.4.

Public Functions


Detailed Description

The QXmlFormatter class indents and pretty-formats XML events.

QXmlFormatter behaves just like its subclass QXmlFormatter but in addition adds, removes and modifies nodes that consists of whitespace only, in order to make produced document be more pleasent for human consumption. In addition it may modify whitespace where insignificant, such as between attributes and the document prolog.

For instance, instead of that "<a><b/><c/><p>Some Text</p></a>" is written out, the following is written:

 <a>
     <b/>
     <c/>
     <p>Some Text</p>
 </a>

Indentation modifies the data, and therefore this can be considered harmful. However, typically this form of indentation is ok for common formats such as XHTML, Docbook and SVG.

The document that QXmlFormatter writes out to the outputDevice() is typically easier for humans to read, at the cost of storage size and computational overhead.

The way QXmlFormatter formats is loosely defined and may change in future versions of Qt. If a deterministic result is of interest, don't pretty format, use QXmlSerializer directly.


Member Function Documentation

QXmlFormatter::QXmlFormatter ( const QXmlQuery & query, QIODevice * outputDevice )

Constructs a formatter that uses the name pool and message handler in query, and writes the result to outputDevice.

int QXmlFormatter::indentationDepth () const

Returns the amount of spaces QXmlFormatter will output for each indentation level.

The default is four.

See also setIndentationDepth().

void QXmlFormatter::setIndentationDepth ( int depth )

Sets the amount of spaces QXmlFormatter writes out for each indentation level to depth.

See also indentationDepth().


Copyright © 2007 Trolltech Trademarks
Qt 4.4.0-tp1