Skip to main content

msgspec-xml

PyPI - Python PyPI - Status PyPI - Version PyPI - License

prek Ruff ty

status-badge

XML Serialization/Deserialization using msgspec.

Installation

pdm add msgspec-xml

Usage

from decimal import Decimal
from typing import Annotated

from msgspec import Struct
from msgspec_xml import decode, encode, Attribute, Value, Wrapper


class Price(Struct):
    currency: Annotated[str, Attribute()]
    cost: Annotated[Decimal, Value()]


class Book(Struct, rename="pascal"):
    title: str  # Implied Element class
    prices: Annotated[list[Price], Wrapper(wrapper="Prices", tag="Price")]


book = Book(
    title="Example Book",
    prices=[
        Price(currency="USD", cost=Decimal("3.99")),
        Price(currency="GBP", cost=Decimal("1.51")),
    ],
)

xml = encode(book)
# <Book>
#   <Title>Example Book</Title>
#   <Prices>
#     <Price currency="USD">3.99</Price>
#     <Price currency="GBP">1.51</Price>
#   </Prices>
# </Book>

decoded = decode(xml, type_=Book)

assert decoded == book

Socials

Social - Matrix

Release files for msgspec-xml 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msgspec-xml 0.3.2
File Size Uploaded
msgspec_xml-0.3.2.tar.gz 82.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for msgspec-xml 0.3.2
File Interpreter ABI Platform
msgspec_xml-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 89.5 kB

Release files / msgspec_xml-0.3.2.tar.gz

Download URL msgspec_xml-0.3.2.tar.gz
Size 82.1 kB
Tags Source
SHA-256 checksum
How to use checksums
85795a75b9968a57e89a5cf4df0217be4719b61897dde71e9ea4263318610360
BLAKE2b-256 checksum
How to use checksums
5cff28231141c2329d0b4c355a07b281fa5521afbffe33530b51482b9dcaef42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / msgspec_xml-0.3.2-py3-none-any.whl

Download URL msgspec_xml-0.3.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3111dfbb6b6533d748e8f3a3db09aac713b4e144f87df16f4389aba4e9131b2c
BLAKE2b-256 checksum
How to use checksums
a007aa57d2d4d690588263f1034b59f39ded53ee43c5f818c2b3b7b5ceb54139
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page