Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a Python equivalent to Perl's XML::Simple?

Tags:

python

perl

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.

like image 518
thedudeabides Avatar asked Jul 31 '26 19:07

thedudeabides


1 Answers

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

like image 151
Paweł Nadolski Avatar answered Aug 02 '26 09:08

Paweł Nadolski