xsdata.formats.dataclass.parsers.xml module

class xsdata.formats.dataclass.parsers.xml.XmlParser(index=<factory>, context=<factory>)[source]

Bases: xsdata.formats.bindings.AbstractParser

index: int = None
queue: List[XmlNode] = None
namespaces: Namespaces = None
objects: List[Tuple[QName, Any]] = None
context: XmlContext = None
parse(source, clazz)[source]

Parse the XML input stream and return the resulting object tree.

Return type

~T

parse_context(context, clazz)[source]

Dispatch elements to handlers as they arrive and are fully parsed.

Raises

ValueError – When the requested type doesn’t match the result object

Return type

~T

queue_node(element)[source]

Queue the next xml node for parsing based on the given element qualified name.

Raises

ParserError – When the parser doesn’t know how to proceed.

dequeue_node(element)[source]

Use the last xml node to parse the given element and bind any child objects.

Returns object

A dataclass object or a python primitive value.

Return type

Optional[~T]

emit_event(event, name, **kwargs)[source]

Call if exist the parser’s hook for the given element and event.