3

You know, something that takes an xml input file and returns a dict, creating keys based on the tag names, and nesting a list of dict's for all the children of each node? If you are familiar with Perl's XML::Simple -- I'm looking for the Python equivalent of that.

I'm tooling around with xml.etree.ElementTree and that will get the job done. But initially I was searching for something that can suck the XML data into a Python dict that I can traverse knowing the tag names.

Aside: Don't bother yelling at me for serializing config data with XML, I already know. If it were up to me, I'd change the format to YAML or JSON. But alas, this legacy system has XML files that I must parse for config data.

thedudeabides
  • 139
  • 1
  • 6

2 Answers2

2

Try Beautiful Soup as described in question Editing XML as a dictionary in python?

Community
  • 1
  • 1
Paweł Nadolski
  • 8,296
  • 2
  • 42
  • 32
1

how about python-simplexml ?

Michał Šrajer
  • 30,364
  • 7
  • 62
  • 85