xml input sanitizing method in standard lib?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Mar 9 17:40:50 EDT 2009


En Mon, 09 Mar 2009 15:30:31 -0200, Petr Muller <afri at afri.cz> escribió:

> Thanks for response and sorry for I wasn't clear first time. I have a
> heap of data (logs), from which I build a XML document using
> xml.dom.minidom. In this data, some xml invalid characters may occur -
> form feed (\x0c) character is one example.
>
> I don't know what else is illegal in xml, so I've searched if there's
> some method how to prepare strings for insertion to a xml doc before I
> start research on a xml spec and write such function on my own.

You don't have to; Python already comes with xml support. Using  
ElementTree to build the document is usually easier and faster:
http://effbot.org/zone/element-index.htm

-- 
Gabriel Genellina




More information about the Python-list mailing list