GitHub - VincentM/xon: XML Object Notation serializer/deserializer

xon is a Python implementation of something I've come to call "XML Object Notation", or XON. It generally conforms to the pickle protocol, which means you interact with it using load and dump functions.

XON arose out of a need to support XML in web-based APIs that already support JSON, and supports the same vocabulary that JSON does. It is based on--and, in fact, the test cases come from--Stefan Goessner's "Converting Between XML and JSON". If you don't use any of xon's extra options, it is intended to work exactly like Goessner describes therein:

>>> import xon
>>> xon.dumps({'foo': {'bar': ['baz', 'quux']}})
'<foo><bar>baz</bar><bar>quux</bar></foo>'
>>> xon.loads('<foo><bar>baz</bar><bar>quux</bar></foo>')
{'foo': {'bar': ['baz', 'quux']}}

Additional options include convertvalues, which will convert ints, floats, and bools in addition to the default behavior of handling strings only, and wrap/unwrap, which deals with the root tag so that the load result and dump parameters are more like typical JSON objects.