bcf.xml_parser#

XML Parser and Serializer factories.

Module Contents#

bcf.xml_parser.T#
class bcf.xml_parser.AbstractXmlParserSerializer#

Bases: Protocol

XML Parser and serializer wrapper.

parse(self, xml: bytes, clazz: Type[T]) T#

Parse an XML file to an object.

Args:

xml: The XML file as bytes. clazz: The class to parse to.

serialize(self, obj: T, ns_map: Optional[dict[str, str]] = None) str#

Serialize an object to XML.

Args:

obj: The object to serialize. ns_map: The namespace map to use.

Returns:

The XML as string.

class bcf.xml_parser.XmlParserSerializer#

XML Parser and serializer wrapper.

parse(self, xml: bytes, clazz: Type[T]) T#

Parse an XML file to an object.

Args:

xml: The XML file as bytes. clazz: The class to parse to.

serialize(self, obj: T, ns_map: Optional[dict[str, str]] = None) str#

Serialize an object to XML.

Args:

obj: The object to serialize. ns_map: The namespace map to use.

Returns:

The XML as string.

bcf.xml_parser.build_serializer(context: Optional[xsdata.formats.dataclass.context.XmlContext] = None) xsdata.formats.dataclass.serializers.XmlSerializer#

Return a serializer for an XML file.

bcf.xml_parser.build_xml_parser(context: Optional[xsdata.formats.dataclass.context.XmlContext] = None) xsdata.formats.dataclass.parsers.XmlParser#

Return a parser for an XML file.