python-xmltodict
Port variant v12
Summary Makes XML feel like JSON (3.12)
BROKEN
Package version 0.14.2
Homepage https://github.com/martinblech/xmltodict
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v13
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 11 NOV 2024, 23:28:05 UTC
Port created 20 AUG 2023, 19:43:36 UTC
Subpackage Descriptions
single # xmltodict `xmltodict` is a Python module that makes working with XML feel like you are working with [JSON], as in this ["spec"]: [Build Status] ```python >>> print(json.dumps(xmltodict.parse(""" ... ... ... elements ... more elements ... ... ... element as well ... ... ... """), indent=4)) { "mydocument": { "@has": "an attribute", "and": { "many": [ "elements", "more elements" ] }, "plus": { "@a": "complex", "#text": "element as well" } } } ``` ## Namespace support By default, `xmltodict` does no XML namespace processing (it just treats namespace declarations as regular node attributes), but passing `process_namespaces=True` will make it expand namespaces for you: ```python >>> xml = """ ... ... 1 ... 2 ... 3 ... ... """ >>> xmltodict.parse(xml, process_namespaces=True) == { ... 'http://defaultns.com/:root': { ... 'http://defaultns.com/:x': '1', ... 'http://a.com/:y': '2', ... 'http://b.com/:z': '3', ... } ... } True ``` It also lets you collapse certain namespaces to shorthand prefixes, or skip them altogether: ```python >>> namespaces = { ... 'http://defaultns.com/': None, # skip this namespace ... 'http://a.com/': 'ns_a', # collapse "http://a.com/" -> "ns_a" ... } >>> xmltodict.parse(xml, process_namespaces=True, namespaces=namespaces) == { ... 'root': { ... 'x': '1', ... 'ns_a:y': '2', ... 'http://b.com/:z': '3', ... }, ... } True ``` ## Streaming mode `xmltodict` is very fast ([Expat]-based) and has a streaming mode with a small memory footprint, suitable for big XML dumps like [Discogs] or [Wikipedia]: ```python >>> def handle_artist(_, artist): ... print(artist['name']) ... return True >>> >>> xmltodict.parse(GzipFile('discogs_artists.xml.gz'), ... item_depth=2, item_callback=handle_artist) A Perfect Circle Fantômas King Crimson Chris Potter ... ```
Configuration Switches (platform-specific settings discarded)
PY312 ON Build using Python 3.12 PY313 OFF Build using Python 3.13
Package Dependencies by Type
Build (only) python312:dev:std
python-pip:single:v12
autoselect-python:single:std
Build and Runtime python312:primary:std
Download groups
main mirror://PYPIWHL/d6/45/fc303eb433e8a2a271739c98e953728422fa61a3c1f36077a49e395c972e
Distribution File Information
20cc7d723ed729276e808f26fb6b3599f786cbc37e06c65e192ba77c40f20aac 9981 xmltodict-0.14.2-py2.py3-none-any.whl
Ports that require python-xmltodict:v12
python-netdoc:v12 Network documentation plugin for NetBox (3.12)