14.9. Source Code for the xMail Application

 CD-ROM reference=14018.txt """ xMail Convert mailboxes to a simple XML form for e-mail messages. XML Processing with Python Sean Mc Grath The Eudora e-mail client stores e-mail messages in mailboxes. The file format is plain text. Individual messages are separated by the string "From ???@???". This program processes a mailbox creating an XML file that conforms to the xmail DTD. """ # Import some standard modules # rfc822 is the module for e_mail header parsing import string,rfc822,StringIO LINUX = 0 EUDORA = 1 def XMLEscape(s): """ Escape XMLs two special characters which may occur within an e-mail message. """ s = string.replace(s,"&","&amp;") s = string.replace(s,"<","&lt;") return s def ProcessMessage(lines,out): ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.