Skip to main content

pydantic-xml extension

Downloads/month Build status License Supported Python versions Code coverage ReadTheDocs status

pydantic-xml is a pydantic extension providing model fields xml binding and xml serialization / deserialization. It is closely integrated with pydantic which means it supports most of its features.

Features

  • pydantic v1 / v2 support

  • flexible attributes, elements and text binding

  • python collection types support (Dict, TypedDict, List, Set, Tuple, …)

  • Union type support

  • pydantic generic models support

  • pydantic computed fields support

  • lxml xml parser support

  • xml.etree.ElementTree standard library xml parser support

What is not supported?

Getting started

The following model fields binding:

class Product(BaseXmlModel):
    status: Literal['running', 'development'] = attr()  # extracted from the 'status' attribute
    launched: Optional[int] = attr(default=None)  # extracted from the 'launched' attribute
    title: str  # extracted from the element text


class Company(BaseXmlModel):
    trade_name: str = attr(name='trade-name')  # extracted from the 'trade-name' attribute
    website: HttpUrl = element()  # extracted from the 'website' element text
    products: List[Product] = element(tag='product', default=[])  # extracted from the 'Company' element's children

defines the XML document:

<Company trade-name="SpaceX">
    <website>https://www.spacex.com</website>
    <product status="running" launched="2013">Several launch vehicles</product>
    <product status="running" launched="2019">Starlink</product>
    <product status="development">Starship</product>
</Company>

See documentation for more details.

Metadata

Release files for pydantic-xml 2.17.1

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

Source distribution (sdist)

Source distribution for pydantic-xml 2.17.1
File Size Uploaded Provenance Actions
pydantic_xml-2.17.1.tar.gz 26.0 kB Without provenance Details for pydantic_xml-2.17.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-xml 2.17.1
File Interpreter ABI Platform Actions
pydantic_xml-2.17.1-py3-none-any.whl Python 3 none any Details for pydantic_xml-2.17.1-py3-none-any.whl

Total release size: 68.1 kB

Release files / pydantic_xml-2.17.1.tar.gz

Download URL pydantic_xml-2.17.1.tar.gz
Size 26.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7ee476ee6ea86055b89a29c1d7dc7ba3763c842f4eff473f31b8b65a86f65f8d
BLAKE2b-256 checksum
How to use checksums
658f577cf8f8898ce3d8bd9c82a7ac61427416c6daeed62e06d15e53d0313c33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.4 Linux/6.11.0-1015-azure

Release files / pydantic_xml-2.17.1-py3-none-any.whl

Download URL pydantic_xml-2.17.1-py3-none-any.whl
Size 42.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27e8762e8b3b85f649b69db7b95f838416db21a7d3fcdce4f5ca6f2bee1397b6
BLAKE2b-256 checksum
How to use checksums
6203f81fff6f1ee4ec4e4b578c7898f704720c2e249162efb6902fdb455d264b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.4 Linux/6.11.0-1015-azure

Security for pydantic-xml 2.17.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.17.1 This release

2 release files No provenance

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