Developer Interface#
pydantic xml serialization/deserialization extension
- class pydantic_xml.BaseXmlModel[source]#
Bases:
BaseModel
Base pydantic-xml model.
- classmethod from_xml_tree(root)[source]#
Deserializes an xml element tree to an object of cls type.
- Parameters:
root (Element) – xml element to deserialize the object from
- Returns:
deserialized object
- Return type:
- classmethod from_xml(source)[source]#
Deserializes an xml string to an object of cls type.
- Parameters:
- Returns:
deserialized object
- Return type:
- to_xml_tree(*, encoder=None, skip_empty=False)[source]#
Serializes the object to an xml tree.
- Parameters:
encoder (Optional[XmlEncoder]) – xml type encoder
skip_empty (bool) – skip empty elements (elements without sub-elements, attributes and text, Nones)
- Returns:
object xml representation
- Return type:
Element
- class pydantic_xml.BaseGenericXmlModel[source]#
Bases:
BaseXmlModel
,GenericModel
Base pydantic-xml generic model.
- class pydantic_xml.XmlAttributeInfo(name=None, ns=None, **kwargs)[source]#
Bases:
XmlEntityInfo
Field xml attribute meta-information.
- class pydantic_xml.XmlElementInfo(tag=None, ns=None, nsmap=None, **kwargs)[source]#
Bases:
XmlEntityInfo
Field xml element meta-information.
- class pydantic_xml.XmlWrapperInfo(path, entity=None, ns=None, nsmap=None, **kwargs)[source]#
Bases:
XmlEntityInfo
Field xml wrapper meta-information.
- pydantic_xml.attr(**kwargs)[source]#
Marks a pydantic field as an xml attribute. Method parameters are identical to
pydantic_xml.XmlAttributeInfo
.
- pydantic_xml.element(**kwargs)[source]#
Marks a pydantic field as an xml element. Method parameters are identical to
pydantic_xml.XmlElementInfo
.