Writing XML Logs

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Apr 12 00:01:17 EDT 2007


En Wed, 11 Apr 2007 11:43:19 -0300, Robert Rawlins - Think Blue  
<robert.rawlins at thinkbluemedia.co.uk> escribió:

> I'm trying to write an application that will log to an XML file, that'll  
> be
> later parsed by another application.

> Can anyone offer any advice on how best to get started with this kind of
> thing? I'm running python 2.4.4 but when I've tried running any examples
> with SAX involved they seem to say 'no module found: sax" or something to
> that effect, I was under the impression that sax came bundled with python
> 2.0 and above?

You could use ElementTree. It's bundled with Python 2.5 but you can  
dowload it from
http://effbot.org/zone/element-index.htm
It's quite simple to use.
Writing XML incrementally is a bit tricky if you want the file to be  
always well formed: you have to overwrite the last closing tag each time.

-- 
Gabriel Genellina




More information about the Python-list mailing list