xsdata.formats.dataclass.serializers.xml module

class xsdata.formats.dataclass.serializers.xml.XmlSerializer(xml_declaration=True, encoding='UTF-8', pretty_print=False, context=<factory>)[source]

Bases: xsdata.formats.bindings.AbstractSerializer

Parameters
  • xml_declaration (bool) – Add xml declaration

  • encoding (str) – Result text encoding

  • pretty_print (bool) – Enable pretty output

  • context (XmlContext) – XmlContext instance

xml_declaration: bool = True
encoding: str = 'UTF-8'
pretty_print: bool = False
context: XmlContext = None
render(obj, namespaces=None)[source]

Convert the given object tree to xml string.

Optionally provide a namespaces instance with a predefined list of namespace uris and prefixes.

Parameters
Return type

str

render_tree(obj, namespaces=None)[source]

Convert a dataclass instance to a nested Element structure.

Optionally provide a namespaces instance with a predefined list of namespace uris and prefixes.

Parameters
Return type

Element

render_node(parent, obj, namespaces)[source]

Recursively traverse the given object and build the xml tree.

Parameters
render_complex_node(parent, obj, namespaces)[source]
Parameters
render_sub_nodes(parent, values, var, namespaces)[source]
Parameters
render_sub_node(parent, value, var, namespaces)[source]
Parameters
render_element_node(parent, value, var, namespaces)[source]
Parameters
render_wildcard_node(parent, value, var, namespaces)[source]
Parameters
set_xsi_type(parent, value, var, namespaces)[source]
Parameters
classmethod next_value(meta, obj)[source]
Parameters