reading xml from python

Philip Semanchuk philip at semanchuk.com
Tue May 11 09:17:48 EDT 2010


On May 11, 2010, at 8:54 AM, Hvidberg, Martin wrote:

> I'm looking for at way to read (and later write) small simple .xml  
> file from Python.
>
> e.g. I would like to read the following from a small ini.xml file  
> into a dictionary.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <initialisation>
> <idrectory>default</idrectory>
> <nosplit>False</nosplit>
> <nobatch>False</nobatch>
> <ubmmode>UBMlight</ubmmode>
> <overwrite_output>True</overwrite_output>
> </initialisation>
> I would prefer a relative simple (not too much creating new classes)  
> way to do this.
>
> Any suggestions appreciated.

Hej Martin,
Did you look in the standard library? ElementTree in the XML section  
of the standard library will do what you want. There are several other  
choices there if you don't like that.


bye
Philip




More information about the Python-list mailing list