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.2 (2026-02-15)

Fixes

  • Fix elements in same choice different branches incorrectly merged as list (#1206)

Features

  • Infer XML required property from typing annotations (#1208)
  • Generate required metadata only for attributes without default values (#1208)

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.2.tar.gz (349.7 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.2-py3-none-any.whl (235.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xsdata-26.2.tar.gz
Algorithm Hash digest
SHA256 c631af71aaa75734f8ce92a08fcf8389d905dee2aab0b5032c9032e9071009a6
MD5 c8b63f958e47b7da73addab4ce8965e2
BLAKE2b-256 2fc971e9e8eac669091fd434ed494d806c8cc37614aecb34ce4c62c283f99abf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xsdata-26.2-py3-none-any.whl
  • Upload date:
  • Size: 235.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85a591a4405d903416afbd4a917e8dda8ea44641a3e66d72134bc2a31b3c16b0
MD5 f0ad72e01167128f640e89fc0dd3a2ca
BLAKE2b-256 d392f0edcbc2f895ecea14a68e492b24c157625e251279a94b172a6b263290e7

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