untangle
- Converts XML to a Python object.
- Siblings with similar names are grouped into a list.
- Children can be accessed with
parent.child, attributes withelement['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 withfoobar.foo_bar,<foo.bar.baz/>can be accessed withfoo_bar_bazand<foo:bar><foo:baz/></foo:bar>can be accessed withfoo_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.PathLikeobject such aspathlib.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)
| File | Size | Uploaded | |
|---|---|---|---|
| untangle-1.3.0.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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}
|