FromXMLString wanted.

Doru-Catalin Togea doru-cat at ifi.uio.no
Wed May 1 06:07:39 EDT 2002


Hi!

I am doing some pretty basic XML parsing using pyxml. My xml data
(not the tags) contains non-english characters. pyxml for ActiveState
Python 2.0 did not complain about that even when I did not provid an
opening line in the xml file stateing the encoding used, like:

<?xml version = '1.0' encoding = 'iso-8859-1'?>

Strange, but true, and I could live with that.

I have now upgraded to ActiveState Python 2.2, pyxml 0.7, and it complains
for the existence of non english characters, EVEN WHEN SPECIFYING THE
ENCODING, as above! Strange again, and unfortunatlly I can not live with
that. :-)

I thought of a hack around it, which would consist of reading in my
xml file into a string, replacing non-english characters with their
UNICODE encodings and parsing the (xml) string. How do I do that?

I used to get a DOM by means of:

-------------
#from xml.dom.ext.reader.Sax import FromXmlStream
from xml.dom.ext.reader.Sax import FromXmlFile
from xml.dom.ext import PrettyPrint

doc = FromXmlFile(xmlFN)
-------------

Now I need the following, or the equivalent from another package:

from xml.dom.ext.reader.Sax import FromXmlString

Or maybe there is another better way of achieving the same goal?

I would appreciate if you could help me out.

Thanks,
Catalin

	<<<< ================================== >>>>
	<<     We are what we repeatedly do.      >>
	<<  Excellence, therefore, is not an act  >>
	<<             but a habit.               >>
	<<<< ================================== >>>>






More information about the Python-list mailing list