Many thanks to Uche for his thoughts and code responding to my frustration working with XML in Python. If you're reading this because you want to write good XML code in Python, read his stuff! He knows much better than I. And he gives clear guidance: use his Amara if you want something Pythonic that can deal with XML.

But reading Uche's posts confirms my main point. There are too many XML choices in Python. And the obvious ones aren't right. Apparently PyXML isn't what I'm supposed to be using (despite it being the default when I type import xml on my Debian box), and if you use it the way the docs say to you're wrong. Urgh!

And while I like what Uche says about Amara, is this the easy way to say "parse an XML document"?

from amara import binderytools
rule = binderytools.preserve_attribute_details(u'*')
doc = binderytools.bind_file("foo.opml", rules=[rule])
He explains why all this is necessary for this example (Amara by default doesn't support XPath attributes), but it's just this kind of complexity that frustrates me. Python's strength is that there's a clear, obvious way to do simple things. But not with XML.

See this response from Uche, with lots of good samples and comments.
techpython
  2005-01-15 16:47 Z