ironpython2 icon indicating copy to clipboard operation
ironpython2 copied to clipboard

pyexpat does not support Python encoding names

Open slozier opened this issue 7 years ago • 1 comments

pyexpat does not support Python encoding names. This is because the names are not understood by System.Xml.XmlReader which is used under the hood.

from xml.etree import ElementTree as ET
text = ET.fromstring(b"<?xml version='1.0' encoding='iso8859'?><a></a>")

A possible solution for this would be to peek at the start of the XML file to get the encoding, do the decoding ourselves and then use a StringReader. Another option would be to peek at the start, and replace the encoding with an alias that XmlReader understands.

slozier avatar Sep 07 '18 17:09 slozier

I think your example needs to use ET.fromstring

slide avatar Sep 14 '18 21:09 slide