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: 25.7 (2025-07-06)

Fixes

  • Ignore dynamic classes in auto-discovery mode. (#1144)
  • Parsing tail content with nested mixed classes (#1151)

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-25.7.tar.gz (345.5 kB view details)

Uploaded Source

Built Distribution

xsdata-25.7-py3-none-any.whl (234.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xsdata-25.7.tar.gz
Algorithm Hash digest
SHA256 1291ef759f4663baadb86562be4c25ebfc0003ca0debae3042b0067663f0c548
MD5 b53d37378f57429dabde8916cc05aed9
BLAKE2b-256 50cfd393286e40f7574c5d662a3ceefcf8e4cd65e73af6e54db0585c5b17c541

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for xsdata-25.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d50b8c39389fd2b7283767a68a80cbf3bc51a3ede9cc3fefb30e84a52c999a9d
MD5 7d5ad996c9c43b47ea2ae8a97263c088
BLAKE2b-256 7910c866e7b0fd57c92a4d5676884b81383005d81f8d7f07f1ac17e9c0ab3643

See more details on using hashes here.

Supported by

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