Simple ElementTree Help

Heston James - Cold Beans heston.james at coldbeans.co.uk
Thu Oct 30 15:17:58 CET 2008


Hello Guys,

 

I have a small element tree task here whereby I need to crack open an XML
file, modify the text for one element and then resave it back again. I'm
currently trying to do this like follows:

 

# Parse the XML file.

application_settings = etree.parse('/configuration/application.xml')

 

# Modify the single_send_mode element.

application_settings.find("single_send_mode").text =
new_configuration["single_send_mode"]

 

# Save the XML file.

application_settings.write("/configuration/application_new.xml")

 

This runs without error however it doesn't save the text into the
'single_send_mode' element and I end up with a configuration file which
contains <single_send_mode /> in it.

 

Can anyone offer any suggestions on how to get this to work properly?

 

Thanks guys, I appreciate it.

 

Heston

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081030/60ecc22e/attachment.html>


More information about the Python-list mailing list