XML Codec ========= Encode/decode XML payloads. Identification and Properties ----------------------------- Codec ID: ``xml`` Properties: +--------------------+-----------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | Name | Type | Default value | Description | +====================+===========+=================+==================================================================================================================================================+ | ``encoding`` | string | ``utf-8`` | encoding: use this to encode the payload. Decoding: assumes the payload follows this encoding if the xml prolog encoding attribute is missing. | +--------------------+-----------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | ``write_prolog`` | boolean | ``True`` | encoding: if True, write the ```` prolog. | +--------------------+-----------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ | ``prettyprint`` | boolean | ``False`` | encoding: if True, pretty print the XML (carriage returns, hard tabs) | +--------------------+-----------+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------+ Overview -------- This codec enables to encode/decode XML strings from/to Testerman message structures. Limitations: * Comments, entity nodes are not decoded (nor can be encoded) * Nested elements are only reported if not preceded by a text. In particular, this makes this codec unsuitable for full XHTML parsing, but should make it more convenient in most testing cases Something like .. code-block:: html
In this text, some elements are nested
will be decoded to: .. code-block:: python ('p', { 'value': u"In this text, some elements are nested" }) I.e. the nested element won't be constructed; whereas: .. code-block:: htmlnested element
will be decoded to .. code-block:: python ('p', { 'children': [ ('i', 'value': u"nested element") ] }) If you don't need to manage attributes and CDATA sections, you may consider CodecXerLite. Decoding ~~~~~~~~ Input: .. code-block:: html