pyxml2obj convert xml to python object and vice versa. This module is inspired by XML::Simple in CPAN
Project description
This module provides only 2 methods, XMLin and XMLout.
XMLin convert xml to python object, and XMLout python object to xml.
This module is inspired by XML::Simple in CPAN,
but some options of XML::Simple are not supported.
Simple example of usage is followings
>>> from pyxml2obj import XMLin, XMLout
>>> xml = '''
.....: <world>
.....: <country area="Asia" lang="ja">Japan</country>
.....: <country area="Europe" lang="fr">France</country>
.....: <country area="Oceania" lang="en">Australia</country>
.....: </world>
.....: '''
>>> world = XMLin(xml)
>>> world
{u'country': [{u'area': u'Asia', 'content': u'Japan', u'lang': u'ja'},
{u'area': u'Europe', 'content': u'France', u'lang': u'fr'},
{u'area': u'Oceania', 'content': u'Australia', u'lang': u'en'}]}
>>>
>>> reverse = XMLout(world)
>>> print reverse
.....: <root>
.....: <country area="Asia" lang="ja">Japan</country>
.....: <country area="Europe" lang="fr">France</country>
.....: <country area="Oceania" lang="en">Australia</country>
.....: </root>
In current version, following options are supported
[XMLin]
keyattr keeproot forcecontent contentkey noattr forcearray grouptags normalizespace valueattr
[XMLout]
keyattr keeproot contentkey noattr rootname xmldecl noescape grouptags valueattr
XMLin convert xml to python object, and XMLout python object to xml.
This module is inspired by XML::Simple in CPAN,
but some options of XML::Simple are not supported.
Simple example of usage is followings
>>> from pyxml2obj import XMLin, XMLout
>>> xml = '''
.....: <world>
.....: <country area="Asia" lang="ja">Japan</country>
.....: <country area="Europe" lang="fr">France</country>
.....: <country area="Oceania" lang="en">Australia</country>
.....: </world>
.....: '''
>>> world = XMLin(xml)
>>> world
{u'country': [{u'area': u'Asia', 'content': u'Japan', u'lang': u'ja'},
{u'area': u'Europe', 'content': u'France', u'lang': u'fr'},
{u'area': u'Oceania', 'content': u'Australia', u'lang': u'en'}]}
>>>
>>> reverse = XMLout(world)
>>> print reverse
.....: <root>
.....: <country area="Asia" lang="ja">Japan</country>
.....: <country area="Europe" lang="fr">France</country>
.....: <country area="Oceania" lang="en">Australia</country>
.....: </root>
In current version, following options are supported
[XMLin]
keyattr keeproot forcecontent contentkey noattr forcearray grouptags normalizespace valueattr
[XMLout]
keyattr keeproot contentkey noattr rootname xmldecl noescape grouptags valueattr
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
pyxml2obj-0.1.1.tar.gz
(11.2 kB
view details)
Built Distribution
pyxml2obj-0.1.1-py2.5.egg
(27.2 kB
view details)
File details
Details for the file pyxml2obj-0.1.1.tar.gz
.
File metadata
- Download URL: pyxml2obj-0.1.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 075dbd41a6679896968e659d0c1663c13faa11f7184df790fd697b37b6719803 |
|
MD5 | 1736fe63aa6895f67b75675f89c02c00 |
|
BLAKE2b-256 | e0a1e4257032600db79722e04bca761dcae6ccbaab59d446d174b6c05fa8e1b7 |
File details
Details for the file pyxml2obj-0.1.1-py2.5.egg
.
File metadata
- Download URL: pyxml2obj-0.1.1-py2.5.egg
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b19586344b1d525be1557f28a9c61b491e33817aaac74af0b1d1a69112bf8296 |
|
MD5 | 5b7afa85fee92c12dec11a3361de2ca1 |
|
BLAKE2b-256 | f7994f753ea5a32b5e32b4632c5ba708a2411405553111b39d5fcdb1e0efe6c2 |