Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stchris/untangle
Converts XML to Python objects
https://github.com/stchris/untangle
pypi python xml
Last synced: 5 days ago
JSON representation
Converts XML to Python objects
- Host: GitHub
- URL: https://github.com/stchris/untangle
- Owner: stchris
- License: mit
- Created: 2011-06-05T10:12:12.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2024-01-19T08:34:06.000Z (10 months ago)
- Last Synced: 2024-09-08T16:45:24.407Z (2 months ago)
- Topics: pypi, python, xml
- Language: Python
- Homepage:
- Size: 186 KB
- Stars: 612
- Watchers: 28
- Forks: 83
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
- awesome-python-resources - GitHub - 27% open · ⏱️ 02.07.2022): (HTML 处理)
README
untangle
========[![Build Status](https://github.com/stchris/untangle/actions/workflows/build.yml/badge.svg)](https://github.com/stchris/untangle/actions)
[![PyPi version](https://img.shields.io/pypi/v/untangle.svg)](https://pypi.python.org/pypi/untangle)[Documentation](http://readthedocs.org/docs/untangle/en/latest/)
* 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 3.7 - 3.10Installation
------------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](https://github.com/conda-forge/untangle-feedstock/issues).
Usage
-----
(See and run examples.py or this blog post: [Read XML painlessly](http://pythonadventures.wordpress.com/2011/10/30/read-xml-painlessly/) for more info)```python
import untangle
obj = untangle.parse(resource)
`````resource`` can be:
* a URL
* a filename
* an XML stringRunning the above code and passing this XML:
```xml
```
allows it to be navigated from the ``untangle``d object like this:```python
obj.root.child['name'] # u'child1'
```Changelog
---------see CHANGELOG.md