xml.sax removing newlines from attribute value?

Fredrik Lundh fredrik at pythonware.com
Thu Sep 29 20:20:06 CEST 2005


Grant Edwards wrote:

> I'm using xml.sax to parse the "datebook" xml file generated by
> QTopiaDesktop.  When I look at the xml file, some of the
> attribute strings have newlines in them (as they are supposed
> to).
>
> However, when xml.sax passes the attributes to my
> startElement() method the newlines seem to have been deleted.
>
> How do I get the un-munged element attribute values?

newlines as in chr(10) rather than 
 ?

if so, the only way is to avoid XML:

    http://www.w3.org/TR/REC-xml/#AVNormalize

if the "yes, I know, but I have good reasons" approach is okay with you,
and you're big enough to defend yourself against the XML-Is-The-Law
crowd, you can use a "sloppy" XML parsers such as sgmlop to deal with
your files:

    http://effbot.org/zone/sgmlop-index.htm

</F> 






More information about the Python-list mailing list