SQL recordset -> XML

Francis Avila francisgavila at yahoo.com
Tue Oct 28 01:27:53 EST 2003


"Richard Shea" <richardshea at fastmail.fm> wrote in message
news:282f826a.0310271500.62fe7a5a at posting.google.com...
...
> I'm in the process of reading the O'Reilly "XML and Python" book and
> there's any amount of support for 'input XML' but nothing really to
> assist with output.
...
> richard shea.


I used xml.sax.saxutils.XMLGenerator for a very simple text->xml conversion.
XMLGenerator is like an inverse SAX: give it sax events (python method
calls), output xml.  It is staggeringly, shockingly poorly documented (even
worse than the rest of the xml.sax package, it seems), which means it's
probably a bad idea to depend on it for anything serious.

It's still not much more sophisticated than the pseudocode you outlined
above, but it takes care of grimy xml character-level details.  It won't
verify against a DTD or even make sure you don't overlap your elements.
(Although the latter could probably be added fairly easily.)

Basic outline of using XMLGenerator here:
http://www.xml.com/pub/a/2003/03/12/py-xml.html

Much more recent and varied coverage:
http://www.xml.com/pub/a/2003/10/15/py-xml.html

There's a little series of "Python and XML" articles over at xml.com, as
you'll see.
--
Francis Avila





More information about the Python-list mailing list