A simple conversion of an lxml.objectify element to a python dictionary.
Project description
A simple conversion of an lxml.objectify element to a python dictionary.
Usage
>>> from lxml_to_dict import lxml_to_dict
>>>
>>> lxml_to_dict(<the lxml.objectfy.Element>)
>>>
>>> root = objectify.Element("root") # <root></root>
>>> b = objectify.SubElement(root, "b") # <root><b></b></root>
>>> b = objectify.SubElement(root, "b") # <root><b></b><b></b></root>
>>> a = objectify.SubElement(root, "a") # <root><b></b><b></b><a></a></root>
>>> lxml_to_dict(root) # {'root': {'b': None, 'b1': None, 'a': None}}
Test
You can run the tests using tox
tox
Publish
To publish a new version of this package your Pypi user needt to be added to the project. (Ask Connor to give you access)
# Update version number in setup.py
python setup.py sdist
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lxml_to_dict-0.1.1.tar.gz
(1.9 kB
view details)
File details
Details for the file lxml_to_dict-0.1.1.tar.gz
.
File metadata
- Download URL: lxml_to_dict-0.1.1.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c2d41c02fd13851883c4a66ca983de0abdd92e63ad49b0701d681feed89f4f6 |
|
MD5 | 5cb994ec64a4a868195a4ca86c6ebff5 |
|
BLAKE2b-256 | 94e1fa808a131b4ba7e322bc169165b9fa311deed03a12fb8b154c2dd2b316a6 |