PythonQt.QtXmlPatterns.QXmlFormatter
QXmlFormatter
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
QXmlFormatter is a subclass of QXmlSerializer that formats the XML output to make it easier for humans to read.
QXmlSerializer outputs XML without adding unnecessary whitespace. In particular, it does not add newlines and indentation. To make the XML output easier to read, QXmlFormatter adds newlines and indentation by adding, removing, and modifying sequence nodes that only consist of whitespace. It also modifies whitespace in other places where it is not significant; e.g., between attributes and in the document prologue.
For example, where the base class QXmlSerializer would output this:
<a><b/><c/><p>Some Text</p></a>
QXmlFormatter outputs this:
<a>
<b/>
<c/>
<p>Some Text</p>
</a>
If you just want to serialize your XML in a human-readable format, use QXmlFormatter as it is. The default indentation level is 4 spaces, but you can set your own indentation value setIndentationDepth().
The newlines and indentation added by QXmlFormatter are suitable for common formats, such as XHTML, SVG, or Docbook, where whitespace is not significant. However, if your XML will be used as input where whitespace is significant, then you must write your own subclass of QXmlSerializer or QAbstractXmlReceiver.
Note that using QXmlFormatter instead of QXmlSerializer will increase computational overhead and document storage size due to the insertion of whitespace.
Note also that the indentation style used by QXmlFormatter remains loosely defined and may change in future versions of Qt. If a specific indentation style is required then either use the base class QXmlSerializer directly, or write your own subclass of QXmlSerializer or QAbstractXmlReceiver. Alternatively, you can subclass QXmlFormatter and reimplement the callbacks there.
QXmlQuery query;
query.setQuery("doc('index.html')/html/body/p[1]");
QXmlFormatter formatter(query, myOutputDevice);
formatter.setIndentationDepth(2);
query.evaluateTo(&formatter);
Source: https://doc.qt.io/archives/qt-5.15/qxmlformatter.html
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
__init__ |
function | (self, *args: Any, **kwargs: Any) -> None |
Native constructor; consult class documentation for supported overloads. (shared captured text) |
atomicValue |
function | (self, value: Any) -> None |
Reimplements: [QXmlSerializer::atomicValue](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#atomicValue)(const QVariant \&value). |
attribute |
function | (self, name: Any, value: str) -> None |
X.attribute(name, value) |
characters |
function | (self, value: str) -> None |
Reimplements: [QXmlSerializer::characters](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#characters)(const QStringRef \&value). |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (shared captured text) |
codec |
function | (self) -> Any |
X.codec() -> PythonQt.QtCore.QTextCodec |
comment |
function | (self, value: str) -> None |
Reimplements: [QXmlSerializer::comment](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#comment)(const QString \&value). |
delete |
function | (self, *args: Any, **kwargs: Any) -> Any |
Deletes the C++ object (at your own risk, my friend!) (shared captured text) |
endDocument |
function | (self) -> None |
Reimplements: [QXmlSerializer::endDocument](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#endDocument)(). |
endElement |
function | (self) -> None |
Reimplements: [QXmlSerializer::endElement](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#endElement)(). |
endOfSequence |
function | (self) -> None |
Reimplements: [QXmlSerializer::endOfSequence](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#endOfSequence)(). |
help |
function | (self, *args: Any, **kwargs: Any) -> Any |
Shows the help of available methods for this class (shared captured text) |
indentationDepth |
function | (self) -> int |
X.indentationDepth() -> int |
inherits |
function | (self, *args: Any, **kwargs: Any) -> Any |
Returns if the class inherits or is of given type name (shared captured text) |
namespaceBinding |
function | (self, nb: Any) -> Any |
|
outputDevice |
function | (self) -> Any |
X.outputDevice() -> PythonQt.QtCore.QIODevice |
processingInstruction |
function | (self, name: Any, value: str) -> None |
X.processingInstruction(name, value) |
setCodec |
function | (self, codec: Any) -> Any |
|
setIndentationDepth |
function | (self, depth: int) -> None |
Sets depth to be the number of spaces [QXmlFormatter](https://doc.qt.io/archives/qt-5.15/qxmlformatter.html) will output for level of indentation. |
startDocument |
function | (self) -> None |
Reimplements: [QXmlSerializer::startDocument](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#startDocument)(). |
startElement |
function | (self, name: Any) -> None |
Reimplements: [QXmlSerializer::startElement](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#startElement)(const QXmlName \&name). |
startOfSequence |
function | (self) -> None |
Reimplements: [QXmlSerializer::startOfSequence](https://doc.qt.io/archives/qt-5.15/qxmlserializer.html#startOfSequence)(). |
whitespaceOnly |
function | (self, value: Any) -> Any |