# XmlParser

class xsdata.formats.dataclass.parsers.XmlParser(config=<factory>, context=<factory>, handler=<class 'xsdata.formats.dataclass.parsers.handlers.lxml.LxmlEventHandler'>)

  Default Xml parser for dataclasses.

  Parameters

    - config (`ParserConfig`) – Parser configuration

    - context (`XmlContext`) – Model context provider

    - handler (`Type`[`XmlHandler`]) – Override default XmlHandler

  Variables

    ms_map – The prefix-URI map generated during parsing

  handler

    alias of `xsdata.formats.dataclass.parsers.handlers.lxml.LxmlEventHandler`

  __eq__(other)

    Return self==value.

  __hash__ = None
  end(queue, objects, qname, text, tail)

    End element notification receiver.

    Pop the last XmlNode from the queue and use it to build and return the resulting object tree with its text and tail content.

    Parameters

      - queue (`List`[`XmlNode`]) – Xml nodes queue

      - objects (`List`[`Tuple`[`Optional`[`str`, `None`], `Any`]]) – List of parsed objects

      - qname (`str`) – Qualified name

      - text (`Optional`[`str`, `None`]) – Text content

      - tail (`Optional`[`str`, `None`]) – Tail content

    Return type

      `bool`

  from_bytes(source, clazz=None)

    Parse the input bytes array return the resulting object tree.

    Return type

      ~T

  from_path(path, clazz=None)

    Parse the input file path and return the resulting object tree.

    Return type

      ~T

  from_string(source, clazz=None)

    Parse the input string and return the resulting object tree.

    Return type

      ~T

  parse(source, clazz=None)

    Parse the input stream or filename and return the resulting object tree.

    Return type

      ~T

  register_namespace(prefix, uri)

    Add the given prefix-URI namespaces mapping if the prefix is new.

    Parameters

      - prefix (`Optional`[`str`, `None`]) – Namespace prefix

      - uri (`str`) – Namespace uri

  start(clazz, queue, objects, qname, attrs, ns_map)

    Start element notification receiver.

    Build and queue the XmlNode for the starting element.

    Parameters

      - clazz (`Optional`[`Type`, `None`]) – Root class type, if it’s missing look for any suitable models from the current context.

      - queue (`List`[`XmlNode`]) – The active XmlNode queue

      - objects (`List`[`Tuple`[`Optional`[`str`, `None`], `Any`]]) – The list of all intermediate parsed objects

      - qname (`str`) – Qualified name

      - attrs (`Dict`) – Attribute key-value map

      - ns_map (`Dict`) – Namespace prefix-URI map