At Elemental I've had a lot of success with a simple module that
converts between Python data structures and XML. I mentioned this code
in a talk at EuroPython this summer and there was quite a bit of
interest in it (despite my emphasis on its limitations).

Encouraged by that interest I'm contributing the code to the PSF for
possible inclusion in the Python standard library. The first step of
contribution is to put it up on the SF tracker:

https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1337648&group_id=5470

Since I'm not all that plugged into the Python XML community I'd like
to get some feedback on the code (I've subscribed to this list
specifically for that purpose).

A quick plug is the little test method included at the end of the code:

def _test():
    class Inner(ElementClass):
        __element__ = "inner"
        __attributes__ = {"special": Boolean}
        __characters__ = "text"
    class Outer(ElementClass):
        __element__ = "outer"
        __attributes__ = {"id": Integer, "name": String}
        __children__ = {Inner: "inner[]"}
    sample = '''<outer id="1" name="foo">
        <inner special="false">blah, blah</inner>
    </outer>'''
    outie = Outer.__parseText__(sample)
    print (outie.id, outie.name)
    for innie in outie.inner:
        print (innie.special, innie.text, str(innie))
    print outie

The output from running this is:

(1, 'foo')
(False, 'blah, blah', '<inner special="false">blah, blah</inner>')
<outer
    id="1"
    name="foo">
  <inner special="false">blah, blah</inner>
</outer>

--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
XML-SIG maillist  -  XML-SIG@python.org
http://mail.python.org/mailman/listinfo/xml-sig

Reply via email to