minidom and encoding problem
ehab_teima at hotmail.com
Wed Jun 5 19:14:14 EDT 2002
I'm using Python 2.1. I wrote classes to create xml document from
scratch. The code worked fine until I hit an encoding problem. The
classes can read text and insert it as is to xml document using
creatTextNode. This text had characters > 127, and I got this error.
File "D:\Python21\lib\xml\dom\minidom.py", line 910, in parse
return _doparse(pulldom.parse, args, kwargs)
File "D:\Python21\lib\xml\dom\minidom.py", line 902, in _doparse
toktype, rootNode = events.getEvent()
File "D:\Python21\lib\xml\dom\pulldom.py", line 234, in getEvent
File "D:\Python21\lib\xml\sax\expatreader.py", line 92, in feed
File "D:\Python21\lib\xml\sax\handler.py", line 38, in fatalError
xml.sax._exceptions.SAXParseException: <unknown>:75:1: not well-formed
I know it's not possible to add an enconding attribute using writexml,
so the generated document only has <?xml version="1.0"?>. Is there any
way to get around this problem. I'd like to be able at least to parse
the document while reading using the proper encoding, such as,
encoding="ISO-8859-1". I'm only using minidom, any ideas how?
Does any body know how to get the rootnode of a document? If I know
the root node, I can add the proper header and then write the root
node using writexml.
More information about the Python-list