Skip to main content

Python XML Binding

Project description

image

Naive XML Bindings for python

image image image image image image


xsData is a complete data binding library for python allowing developers to access and use XML and JSON documents as simple objects rather than using DOM.

The code generator supports XML schemas, DTD, WSDL definitions, XML & JSON documents. It produces simple dataclasses with type hints and simple binding metadata.

The included XML and JSON parser/serializer are highly optimized and adaptable, with multiple handlers and configuration properties.

xsData is constantly tested against the W3C XML Schema 1.1 test suite.

Getting started

$ # Install all dependencies
$ pip install xsdata[cli,lxml,soap]
$ # Generate models
$ xsdata generate tests/fixtures/primer/order.xsd --package tests.fixtures.primer
>>> from tests.fixtures.primer import PurchaseOrder
>>> from xsdata.formats.dataclass.parsers import XmlParser
>>>
>>> parser = XmlParser()
>>> order = parser.parse("tests/fixtures/primer/sample.xml", PurchaseOrder)
>>> order.bill_to
Usaddress(name='Robert Smith', street='8 Oak Avenue', city='Old Town', state='PA', zip=Decimal('95819'), country='US')

Check the documentation for more ✨✨✨

Features

Code Generator

  • XML Schemas 1.0 & 1.1
  • WSDL 1.1 definitions with SOAP 1.1 bindings
  • DTD external definitions
  • Directly from XML and JSON Documents
  • Extensive configuration to customize output
  • Pluggable code writer for custom output formats

Default Output

  • Pure python dataclasses with metadata
  • Type hints with support for forward references and unions
  • Enumerations and inner classes
  • Support namespace qualified elements and attributes

Data Binding

  • XML and JSON parser, serializer
  • PyCode serializer
  • Handlers and Writers based on lxml and native xml python
  • Support wildcard elements and attributes
  • Support xinclude statements and unknown properties
  • Customize behaviour through config

Changelog: 26.1 (2026-01-20)

Fixes

  • Fixed missing imports on inheriting multiple mixins for the same class (#1156)
  • Fixed choice elements with minOccurs <= 1 not marked as optional
  • Fixed incorrect max_occurs for elements in different choice blocks (#1179)
  • Fixed AttributeError when retrieving subclasses from cython packages (#1200)

Features

  • Added flag for specifying extensions (#1168)
  • Added support for python 3.14 (#1173)
  • Switched to Sequence when using generic containers (#1201)

Deprecations

  • Removed Python 3.9 support (#1189) (#1191)
  • Removed cli options union-type, kw-only, postponed-annotations are now always enabled
  • Removed xsdata shorthand (#1128)

Project details


Download files

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

Source Distribution

xsdata-26.1.tar.gz (348.5 kB view details)

Uploaded Source

Built Distribution

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

xsdata-26.1-py3-none-any.whl (235.4 kB view details)

Uploaded Python 3

File details

Details for the file xsdata-26.1.tar.gz.

File metadata

  • Download URL: xsdata-26.1.tar.gz
  • Upload date:
  • Size: 348.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xsdata-26.1.tar.gz
Algorithm Hash digest
SHA256 dcae2c0e5f329f1b4e09a2d148c96941c9556616bb5e3418970a63c5eb2cd831
MD5 e02bacdc6b06dcf3a020ba83268d816e
BLAKE2b-256 249fc1b0fa54f2b3f43989015668daddd8bd50d3bf3461ba8b79fdeb8000b27d

See more details on using hashes here.

File details

Details for the file xsdata-26.1-py3-none-any.whl.

File metadata

  • Download URL: xsdata-26.1-py3-none-any.whl
  • Upload date:
  • Size: 235.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xsdata-26.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa02adf1b75668e7b685f4de3c4507e4aa31af3f2e2210fd45aa2f0e4a637a99
MD5 c57719eef787c49b3e428c750cfb8d20
BLAKE2b-256 7b4837775c15adba3070f0af934a6617696a608a75f2e01be37a454e298cf32c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page