jxmlease
Version: 1.0.1¶
Welcome¶
jxmlease converts between XML and intelligent Python data structures.
For a quick start, you can use the parse()
method to convert a
block of XML to a Python data structure. This example parses xml
and uses
the XMLDictNode.prettyprint()
method to display the result:
>>> xml = "<a><b><c>foo</c><c>bar</c></b></a>"
>>> parse(xml).prettyprint()
{u'a': {u'b': {u'c': [u'foo', u'bar']}}}
Or, you can use the XMLDictNode
class to convert a Python data
structure to an intelligent XML data structure. The following example creates an
XMLDictNode
object from data_structure
and outputs the resulting
XML using the XMLNodeBase.emit_xml()
method:
>>> data_structure = {u'a': {u'b': {u'c': [u'foo', u'bar']}}}
>>> print XMLDictNode(data_structure).emit_xml()
<?xml version="1.0" encoding="utf-8"?>
<a>
<b>
<c>foo</c>
<c>bar</c>
</b>
</a>