lamp

Reading XML files with different encoding, like ISO-8859-1

Published 10 February 08 04:27 PM | Frederick.Chapleau

I used a XMLDocument to load a file with the encoding ISO-8859-1, but accents were lost. The problem is that the inner FileReader is using the default UTF-8 encoding, or not detecting the current file encoding. To solve the problem, I used a XmlTextReader, like this.

XmlTextReader rdr = new XmlTextReader(xmlFile);

XmlDocument doc = new XmlDocument();

doc.Load(rdr);

And this solved the issue.

-f.

Filed under:

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Protected by FormShield
Refresh
Listen
Please enter the characters shown on the image


Code: