An easy way to write XML in Python

David Mertz's gnosis utilities include the module gnosis.xml.objectify, which makes parsing XML in python as simple as could be. from gnosis.xml import objectify xmltext = """<?xml version="1.0" encoding="UTF-8"?> <root><first canned="true" yummy="false">spam</first><second>egg</second></root>""" inst = objectify.make_instance(xmltext) print "first:", inst.first.PCDATA print "  canned:", inst.first.canned print "  yummy:", inst.first.yummy print "second:", inst.second.PCDATA Output: first: spam   canned: true   […]