Re.: reading xml from python - Sum-up
Hvidberg, Martin
mhv at dmu.dk
Wed May 12 03:08:49 EDT 2010
Thanks to all - Just to give a positive feed back.
The following solution works for me:
from xml.etree.ElementTree import ElementTree
tree = ElementTree()
tree.parse('inifile.xml')
dicIni = dict((child.tag, child.text) for child in tree.getroot().getchildren())
:-) Martin
This email is made of 100% recycled bytes ...
________________________________
From: Hvidberg, Martin
Sent: Tuesday, May 11, 2010 2:54 PM
To: 'python-list at python.org'
Subject: reading xml from python
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.
:-) Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100512/41a858c1/attachment.html>
More information about the Python-list
mailing list