Need help with untangle?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

stchris
502 Stars 73 Forks MIT License 195 Commits 26 Opened issues

Description

Converts XML to Python objects

Services available

!
?

Need anything else?

Contributors list

# 142,171
Shell
XML
pypi
built-a...
39 commits
# 82,795
XML
pypi
HTML
urban-p...
8 commits
# 151,394
pypi
React
Electro...
Linux
5 commits
# 52,493
Python
Shell
XML
pypi
3 commits
# 175,798
Shell
parser-...
XML
pypi
3 commits
# 229,524
XML
pypi
Django
python3
2 commits
# 164,680
XML
pypi
psql
postgre...
1 commit
# 88,006
XML
pypi
tslint
node
1 commit

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
    _
     can be accessed with 
    foobar.foo_bar
    ,
     can be accessed with 
    foo_bar_baz
    and
     can be accessed with 
    foo_bar.foo_baz
  • Works with Python 2.7 and 3.4, 3.5, 3.6, 3.7, 3.8 and pypy

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:

    

allows it to be navigated from the

untangle
d object like this:
obj.root.child['name'] # u'child1'

Changelog

see CHANGELOG.md

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.