Skip to main content

untangle

Build Status PyPi version

Documentation

  • Converts XML to a Python object.
  • Siblings with similar names are grouped into a list.
  • Children can be accessed with parent.child, attributes with element['attribute'].
  • You can call the parse() method with a filename, an URL or an XML string.
  • Substitutes -, . and : with _ <foobar><foo-bar/></foobar> can be accessed with foobar.foo_bar, <foo.bar.baz/> can be accessed with foo_bar_baz and <foo:bar><foo:baz/></foo:bar> can be accessed with foo_bar.foo_baz

Installation

With pip:

pip install untangle

Usage

(See and run examples.py or this blog post: Read XML painlessly for more info)

import untangle

obj = untangle.parse(resource)

resource can be:

  • a URL
  • a filename (a string or an os.PathLike object such as pathlib.Path)
  • an XML string

Running the above code and passing this XML:

<?xml version="1.0"?>
<root>
	<child name="child1"/>
</root>

allows it to be navigated from the untangled object like this:

obj.root.child["name"]  # u'child1'

Development

untangle uses uv for builds and virtualenv management:

$ uv sync

Run tests:

$ uv run pytest

Run linter:

$ uv run ruff check .

Run formatter checks:

$ uv run ruff format --check

Run type hint checks:

$ uv run ty check .

Changelog

see CHANGELOG.md

Release files for untangle 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for untangle 1.3.0
File Size Uploaded
untangle-1.3.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for untangle 1.3.0
File Interpreter ABI Platform
untangle-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / untangle-1.3.0.tar.gz

Download URL untangle-1.3.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2a0add33ecd61faf155ace1fcdb6fd9ed74f42ec976942b221f6c7f6c0a47bef
BLAKE2b-256 checksum
How to use checksums
18d9cb5cfcf1f92fc97c0eaf46f1f08bad8f49cfcae15a653874cb827a8593e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / untangle-1.3.0-py3-none-any.whl

Download URL untangle-1.3.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
831ef1f84a0bc501072e4ea7542ca63c1e03ce09c9a8a5d364d9551afde200c2
BLAKE2b-256 checksum
How to use checksums
9fadb631f93c5d1f4c7d8bfe3f11cd6afd1256cb7b5a5b45891d56c9a8d02b21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.1

2 release files

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page