Skip to main content
Version: 0.0.5 (stable)

agrag.loaders.prose.XmlLoader

Bases: ProseLoader

Reads an XML file as the text of its elements.

The loader drops the tags and joins the text it finds with newlines. Text in an element with mixed content is split at its child elements. Text inside a CDATA section is not kept.

Attributes:

Functions:

  • is_available – Return whether the package that the loader's extra installs is present.
  • load – Yield one prose Document from the text of the elements.

extensions​

extensions = frozenset({'.xml'})

extra​

extra: str | None = None

extra_module​

extra_module: str | None = None

family​

family = DocumentFamily.PROSE

is_available​

is_available() -> bool

Return whether the package that the loader's extra installs is present.

A loader with no extra is always available. The check looks the module up without importing it, so an installed package that fails to import still counts.

load​

load(source:SourceRef, stream:BinaryIO, opts:ReadOptions, *, start_at:int = 0) -> Iterator[Document]

Yield one prose Document from the text of the elements.

Parameters:

  • source (SourceRef) – The source to read.
  • stream (BinaryIO) – The open binary stream for the source.
  • opts (ReadOptions) – The read options for this call.
  • start_at (int) – Ignored by prose loaders.

Yields:

  • Document – One Document holding the element text.

mime_types​

mime_types: frozenset[str] = frozenset()