A Python module that converts XML to and from Python dictionaries, making XML feel like JSON.
xmltodict is a Python module that converts XML data into Python dictionaries and vice versa, allowing developers to work with XML using familiar dictionary and list operations. It solves the problem of cumbersome XML parsing by providing a JSON-like interface, making XML manipulation as straightforward as handling JSON. The library is built on Expat for fast parsing and supports streaming for large files.
Python developers who need to parse, generate, or manipulate XML data in their applications, especially those dealing with web APIs, data feeds, or large XML dumps. It's also useful for developers transitioning from JSON workflows who encounter XML data sources.
Developers choose xmltodict for its simplicity and performance—it eliminates the need for complex XML DOM or SAX APIs by providing a intuitive dictionary-based interface. Its streaming mode and small memory footprint make it ideal for large XML files, while roundtripping support allows easy XML generation from Python data structures.
Python module that makes working with XML feel like you are working with JSON
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Converts XML to Python dictionaries with intuitive syntax, making XML manipulation as straightforward as handling JSON, as shown in the initial parsing example.
Built on Expat for speed and offers a streaming mode with minimal memory footprint, ideal for large dumps like Wikipedia or Discogs, demonstrated in the command-line examples.
Supports configurable namespace processing with options to expand URIs or collapse to prefixes, providing control over complex XML namespaces.
Enables roundtripping via the unparse() method for easy XML generation from dictionaries, though with noted limitations like nested list handling.
The README explicitly states it doesn't preserve every XML nuance, such as attribute order or multiple top-level comments, limiting use in strict XML scenarios.
Relies on Python's XMLGenerator which doesn't validate element names, leading to a disputed CVE and potential risks with untrusted input, as discussed in the security notes.
Features like expand_iter for nested lists break roundtripping, and empty lists are skipped in output, requiring workarounds for consistent bidirectional conversion.