[XML-SIG] ANN: XMLBuilder 1.1

Mike Hostetler hostetlerm at gmail.com
Thu Aug 26 18:16:50 CEST 2004


Thanks to a few comments, I'm introducing XMLBuilder 1.1

I thought changing the addition to be more like everyone (including
me) would expect to be harder than it was -- it was mostly a mistake
on my part.

Now you can also put in XML by nesting dictionaries.  Also, because of
this, you have to use "attr","attrs","attributes" for creating
attributes -- a fair trade-off.

The latest example run:

       b1 = XMLBuilder()
       b1.contacts = {"owner":"thehaas at binary.net"}
       print b1
        <?xml version="1.0" ?>
<contacts><owner>thehaas at binary.net</owner></contacts>


        b2 = XMLBuilder()
        b2.name = {"person": {"attr": {"type":"friend"},"last":"flintstone",
                           "first":"fred"}}
        print b2
        <?xml version="1.0" ?>
<name><person type="friend"><last>flintstone</last><first>fred</first></person>\
</name>

        b1.contacts = {"owner":"thehaas at binary.net", "contact":b2}
        print b1
        <?xml version="1.0" ?>
<contacts><owner>thehaas at binary.net</owner><contact><name><person type="friend"\
><last>flintstone</last><first>fred</first></person></name></contact></contacts\
>

        # adding example
        b1.contacts = {"owner":"thehaas at binary.net"}
        print b1+b2
     <?xml version="1.0" ?>
<contacts><owner>thehaas at binary.net</owner><name><person type="friend"><last>fl\
intstone</last><first>fred</first></person></name></contacts>


The latest version is here:
   http://users.binary.net/thehaas/lab/files/xmlbuilder.py

Any comments are appreciated!
-- 
Mike Hostetler
thehaas at binary.net
http://www.binary.net/thehaas


More information about the XML-SIG mailing list