Skip to main content

Convert XML documents into Python objects

Project description

untangle

Build Status PyPi version Code style: black

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
  • Works with Python 3.7 - 3.10

Installation

With pip:

pip install untangle

With conda:

conda install -c conda-forge untangle

Conda feedstock maintained by @htenkanen. Issues and questions about conda-forge packaging / installation can be done here.

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
  • 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'

Changelog

see CHANGELOG.md

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

untangle-1.2.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

untangle-1.2.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file untangle-1.2.0.tar.gz.

File metadata

  • Download URL: untangle-1.2.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for untangle-1.2.0.tar.gz
Algorithm Hash digest
SHA256 dda75a60bfe69d76f116c3aea91c478885d25288d798f290201daa1400c1b5d4
MD5 74e3a16af8c3e26c6214ac1a82fe2bfd
BLAKE2b-256 43182086eec49e2a83d51a3c48f96725fe1655b5195229e8fa54283ce45ad3b5

See more details on using hashes here.

File details

Details for the file untangle-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: untangle-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for untangle-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a527b234e930df124120684cbcd3dcc24061bf3c9a95fe0e1dfc5e51835a2a2c
MD5 7b352932941685c77b952896dec7bf92
BLAKE2b-256 427f942663bed7872dbb7f02e35d4f455d7942465423adb213634068140b37e0

See more details on using hashes here.

Supported by

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