package similar to XML::Simple
Peter Hansen
peter at engcorp.com
Wed Jan 28 09:24:48 EST 2004
Paulo Pinto wrote:
>
> does anyone know of a Python package that
> is able to load XML like the XML::Simple
> Perl package does?
>
> For those that don't know it, this package
> maps the XML file to a dictionary.
A simple dictionary is insufficient to represent XML in general,
so perhaps you're talking about a subset of XML, maybe with no
attributes, and where the order of the child elements doesn't
matter? Or something else?
Or do you really mean something like a multiply-nested
dictionary, perhaps with lists as well?
> Of course I can build such a package myself
> but it would be better if it already exists :)
We were able to build something similar by stripping down
Fredrik Lundh's elementtree until we had little more than the
calls to the expat parser (i.e. we used his source as a tutorial
on using expat :-), so if this is something like the XML-subset
I mention above, you could do it in an hour or so from scratch
if you knew Python well.
-Peter
More information about the Python-list
mailing list