"Edward K. Ream" <[EMAIL PROTECTED]> writes: > Can anyone tell me how the content handler can determine the encoding of the > file? Can sax provide this info?
Try this: <code> from xml.parsers import expat s = """<?xml version='1.0' encoding='iso-8859-1'?> <book> <title>Title</title> <chapter>Chapter 1</chapter> </book> """ class MyParser(object): def XmlDecl(self, version, encoding, standalone): print "XmlDecl", version, encoding, standalone def Parse(self, data): Parser = expat.ParserCreate() Parser.XmlDeclHandler = self.XmlDecl Parser.Parse(data, 1) parser = MyParser() parser.Parse(s) </code> -- HTH, Rob -- http://mail.python.org/mailman/listinfo/python-list