Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Regex to find unicode characters that are not valid in XML
- # http://en.wikipedia.org/wiki/Valid_characters_in_XML
- invalid_xml_chars = re.compile(u'[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F]')
- # Create the temp file to hold the XML
- xml = StringIO()
- s = unicode(xml_tpl.format(data_obj))
- xml.write(re.sub(invalid_xml_chars, u"", s).encode('utf-8', 'xmlcharrefreplace'))
- xml.seek(0)
- ftp = FTP(credential..)
- # Set connection mode to active
- ftp.set_pasv(False)
- ftp.storbinary("STOR file.xml", xml)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement