bcf.xml_parser

XML Parser and Serializer factories.

Module Contents

class bcf.xml_parser.AbstractXmlParserSerializer

Bases: Protocol

XML Parser and serializer wrapper.

parse(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(obj: object, ns_map: dict[str, str] | None = 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(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(obj: object, ns_map: dict[str | None, str] | None = 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.

context
parser
serializer
bcf.xml_parser.build_serializer(context: xsdata.formats.dataclass.context.XmlContext | None = None) xsdata.formats.dataclass.serializers.XmlSerializer

Return a serializer for an XML file.

bcf.xml_parser.build_xml_parser(context: xsdata.formats.dataclass.context.XmlContext | None = None) xsdata.formats.dataclass.parsers.XmlParser

Return a parser for an XML file.

bcf.xml_parser.T