xml
xsdata.formats.dataclass.serializers.xml
XmlSerializer
dataclass
Bases: EventGenerator
Xml serializer for data classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | SerializerConfig | The serializer config instance | SerializerConfig() |
context | XmlContext | The models context instance | XmlContext() |
writer | type[XmlWriter] | The xml writer class | DEFAULT_XML_WRITER |
Source code in xsdata/formats/dataclass/serializers/xml.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
render(obj, ns_map=None)
Serialize the input model instance to xml string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj | Any | The input model instance to serialize | required |
ns_map | Optional[dict] | A user defined namespace prefix-URI map | None |
Returns:
Type | Description |
---|---|
str | The serialized xml string output. |
Source code in xsdata/formats/dataclass/serializers/xml.py
29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
write(out, obj, ns_map=None)
Serialize the given object to the output text stream.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
out | TextIO | The output text stream | required |
obj | Any | The input model instance to serialize | required |
ns_map | Optional[dict] | A user defined namespace prefix-URI map | None |
Source code in xsdata/formats/dataclass/serializers/xml.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|