Skip to main content
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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_xml-2.21.1.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_xml-2.21.1-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_xml-2.21.1.tar.gz.

File metadata

  • Download URL: pydantic_xml-2.21.1.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-1020-azure

File hashes

Hashes for pydantic_xml-2.21.1.tar.gz
Algorithm Hash digest
SHA256 43488d244375d9fbaa593d8c0435f8b0a940d7e594fded647383ff223af2baac
MD5 bfca822e74e86ec4c873c550706b9468
BLAKE2b-256 2c335a24758a8fdf2b3ed09799fd426681eb2ff3a3a2d21ab08697c54730935e

See more details on using hashes here.

File details

Details for the file pydantic_xml-2.21.1-py3-none-any.whl.

File metadata

  • Download URL: pydantic_xml-2.21.1-py3-none-any.whl
  • Upload date:
  • Size: 43.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.6 Linux/6.17.0-1020-azure

File hashes

Hashes for pydantic_xml-2.21.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0469622c344485c328213fa18ff49542b814a9770afcfc6810e9771401d9236
MD5 2f1f21e15e215716f1dd1963e5a2e3f9
BLAKE2b-256 3959a3b3c08b6755d46d38a3f499dbc525a0eedcf575a6e2cc0dbad3d4755bb1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.21.1 This release

2 files

2.21.0

2 files

2.20.0

2 files

2.19.0

2 files

2.18.0

2 files

2.17.3

2 files

2.17.2

2 files

2.17.1

2 files

2.17.0

2 files

2.16.0

2 files

2.15.0

2 files

2.14.3

2 files

2.14.2

2 files

2.14.1

2 files

2.14.0

2 files

2.13.1

2 files

2.13.0

2 files

2.12.1

2 files

2.12.0

2 files

2.11.0

2 files

2.10.0

2 files

2.9.2

2 files

2.9.1

2 files

2.9.0

2 files

2.8.1

2 files

2.8.0

2 files

2.7.0

2 files

2.6.0

2 files

2.5.0

2 files

2.4.0

2 files

2.3.0

2 files

2.2.4

2 files

2.2.3

2 files

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

1.0.0

2 files

0.7.0

2 files

0.6.3

2 files

0.6.2

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 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