Simple XML-to-Python conversion

Diez B. Roggisch deetsNOSPAM at web.de
Sat Mar 19 07:53:55 EST 2005


> If I used a simple INI file or CSV file, I would simply have to parse
> my file once and match the name with the value.  Why is it necessary to
> parse a document once and then re-parse your information into a format
> that you can use.  This seems absurd to me.  Any thoughts on this?  Do
> I even have the correct understanding of how this is done?

The problem here is that xml allows for modelling data-structures with
parent-child relationships and preserve the order of elements. So it's much
more capable than ini and csv - but that comes for the cost of more
elaborated and somewhat complicated apis. A configuration file is only
_one_ possible use case.

So if you already found that ini-Files suit your needs - why don't you use
them? There is a ConfigfileParser in python to parse these, and it gives
you easy access to the defined sections and fields. And don't bother if
ini-Files are popular on linux or not - on linux a great deal of different
formats is popular, and nobody seems to care too much. E.g. samba uses
ini-style config, too.

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list