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
cpz-1.0.1.tar.gz
(11.3 kB
view hashes)
Built Distribution
cpz-1.0.1-py2-none-any.whl
(28.9 kB
view hashes)