A simple xml parse and build library.
Project description
Brief
A simple xml parse and build library.
Installation
pip install db0905
Examples
- xml to python object
>>> import db0905
>>> xml = '<demo><foo>foo</foo><bar>bar</bar></demo>'
>>> db0905.loads(xml)
{'bar': 'bar', 'foo': 'foo'}
>>> db0905.loads(xml, strip_root=False)
{'demo': {'bar': 'bar', 'foo': 'foo'}}
>>> xml = '<demo><foo>foo</foo><bar>1</bar><bar>2</bar></demo>'
>>> db0905.loads(xml)
{'bar': ['1', '2'], 'foo': 'foo'}
- python object to xml
>>> data = {'demo':{'bar': ['1', '2'], 'foo': '<foo>'}}
>>> db0905.dumps(data)
'<?xml version="1.0" encoding="utf-8"?><demo><foo><![CDATA[<foo>]]></foo><bar><![CDATA[1]]></bar><bar><![CDATA[2]]></bar></demo>'
>>> db0905.dumps(data, cdata=False)
'<?xml version="1.0" encoding="utf-8"?><demo><foo><foo></foo><bar>1</bar><bar>2</bar></demo>'
>>> print db0905.dumps(data, indent=' ' * 4)
<?xml version="1.0" encoding="utf-8"?>
<demo>
<foo><![CDATA[<foo>]]></foo>
<bar><![CDATA[1]]></bar>
<bar><![CDATA[2]]></bar>
</demo>
Documentation
Changelog
See changelog
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
db0905-1.0.1.tar.gz
(11.3 kB
view details)
Built Distribution
db0905-1.0.1-py2-none-any.whl
(19.2 kB
view details)
File details
Details for the file db0905-1.0.1.tar.gz
.
File metadata
- Download URL: db0905-1.0.1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f42269208f0c6d18458c173392a5a03f08d29272e3506a26ed4978a88a0e1e |
|
MD5 | 244fcea7d216566079d6fad7433fa614 |
|
BLAKE2b-256 | afed2c0de2c5d8cb5630c213915670f40789d736e9dbf5cf439ecdc818dad5c9 |
File details
Details for the file db0905-1.0.1-py2-none-any.whl
.
File metadata
- Download URL: db0905-1.0.1-py2-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 827a2219a43b0e22ae5daf456151887e49c87dc3ac0a84ab3bee9b5f4d328a6c |
|
MD5 | 9ae1ca2b8b37a56b3d8ec4ce1d035664 |
|
BLAKE2b-256 | a84a5886b3af815dbb3b63d8a5caebb5b3370fd53e660e25c7e8382cb02e308e |