generating XML from config using python
<p>Please tell me how I can get out of *.conf [section name] and the value of the first parameter (after the name of the section) and on their basis to create a XML file using python? I have a very simple config file, but each section is more than one option. Thank you in advance.</p>

<pre><code>import xml.etree.cElementTree as ET # on Python 3.3+ use xml.etree.ElementTree instead
import configparser

config = configparser.ConfigParser()
config.read('sipusers.conf')    

Main = ET.Element("Main")
ET.SubElement(Main, "TCMIPPhoneDirectory", clearlight="true")
ET.SubElement(Main, "Title").text = "Phonelist"
ET.SubElement(Main, "Prompt").text = "Prompt"

for section in config.sections():
    Child = ET.SubElement(Main, "DirectoryEntry")
    ET.SubElement(Child, "Name").text = section
    ET.SubElement(Child, "Telephone").text = config.get(section,'username') 

xml = ET.ElementTree(Main)
xml.write("phonebook.xml")
</code></pre>

python xml