Skip to content

PythonQt.QtXmlPatterns.QXmlSerializer

QXmlSerializer

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

QXmlSerializer translates an XQuery sequence, usually the output of an QXmlQuery, into XML. Consider the example:

QXmlQuery query;
query.setQuery("doc('index.html')/html/body/p[1]");

QXmlSerializer serializer(query, myOutputDevice);
query.evaluateTo(&serializer);

First it constructs a query that gets the first paragraph from document index.html. Then it constructs an instance of this class with the query and myOutputDevice. Finally, it evaluates the query, producing an ordered sequence of calls to the serializer's callback functions. The sequence of callbacks transforms the query output to XML and writes it to myOutputDevice.

QXmlSerializer will:

  • Declare namespaces when needed,
  • Use appropriate escaping, when characters can't be represented in the XML,
  • Handle line endings appropriately,
  • Report errors, when it can't serialize the content, e.g., when asked to serialize an attribute that is a top-level node, or when more than one top-level element is encountered.

If an error occurs during serialization, result is undefined unless the serializer is driven through a call to QXmlQuery::evaluateTo().

If the generated XML should be indented and formatted for reading, use QXmlFormatter.

Source: https://doc.qt.io/archives/qt-5.15/qxmlserializer.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: [QAbstractXmlReceiver::atomicValue](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#atomicValue)(const QVariant \&value).
attribute function (self, name: Any, value: str) -> None X.attribute(name, value)
characters function (self, value: str) -> None Reimplements: [QAbstractXmlReceiver::characters](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.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: [QAbstractXmlReceiver::comment](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.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: [QAbstractXmlReceiver::endDocument](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#endDocument)().
endElement function (self) -> None Reimplements: [QAbstractXmlReceiver::endElement](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#endElement)().
endOfSequence function (self) -> None Reimplements: [QAbstractXmlReceiver::endOfSequence](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#endOfSequence)().
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
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) -> None Reimplements: [QAbstractXmlReceiver::namespaceBinding](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#namespaceBinding)(const QXmlName \&name).
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) -> None Sets the codec the serializer will use for encoding its XML output.
startDocument function (self) -> None Reimplements: [QAbstractXmlReceiver::startDocument](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#startDocument)().
startElement function (self, name: Any) -> None Reimplements: [QAbstractXmlReceiver::startElement](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#startElement)(const QXmlName \&name).
startOfSequence function (self) -> None Reimplements: [QAbstractXmlReceiver::startOfSequence](https://doc.qt.io/archives/qt-5.15/qabstractxmlreceiver.html#startOfSequence)().
whitespaceOnly function (self, value: Any) -> Any (shared captured text)